When you want the data from a UI Part Metadata Item and you're working in JavaScript, the Aptify JavaScript API provides a handy interface.
Step-by-step guide
Know the Table Name you want to access – not the Name of the UI Part Metadata Item itself, but of one of its Tables that has Include In Data Set checked.
Code Block language js linenumbers true var upmiTable = "entityCards";
Call Aptify.framework.utility.cache.getMetaData and use the UI Part Metadata Item in the callback.
Code Block language js title Access a UI Part Metadata Item linenumbers true Aptify.framework.utility.cache.getMetaData(upmiTable, function (data) { // If we end up in the callback, we know that we've succeeded // data holds the JSON array tied to the upmiTable key });
So, for the Entity Cards array, which has a JSON UI Part that looks like this:
Code Block language js title Entity Cards UI Part Metadata Item JSON linenumbers true {"entityCards": [ {"id":"1","name":"Persons Default", ...,
...
"uiParts": [ {"id":"1","entityCardId":"1", ...} ] }, {"id":"2","name":"Companies Default", ..., "uiParts": [ {"id":"2","entityCardId":"2", ...} ] }, ... ] }
The "data" parameter passed to the callback function will look like this:
Code Block language js title JSON Array From getMetaData() linenumbers true [ {"id":"1","name":"Persons Default", ..., "uiParts": [ {"id":"1","entityCardId":"1", ...} ] }, {"id":"2","name":"Companies Default", ..., "uiParts": [ {"id":"2","entityCardId":"2", ...} ] }, ... ]
Note Because getMetaData() is a function that accesses the cache, it's possible for it to return synchronously if the requested metadata is already in the browser's local storage:
Code Block language js title Synchronous Use of getMetaData() linenumbers true var data = Aptify.framework.utility.cache.getMetaData(upmiTable);
However, you as the programmer are not in control of the cache, so the best practice is to stick to using the function asynchronously.
Related articles
Filter by label (Content by label) | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|