If you have a comment on this topic, contact Aptify Documentation. If you want to return to the Aptify Community Site, please click here.

Access a UI Part Metadata Item (via JavaScript API)

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

  1. 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.

    var upmiTable = "entityCards";
  2. Call Aptify.framework.utility.cache.getMetaData and use the UI Part Metadata Item in the callback.

    Access a UI Part Metadata Item
    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:

    Entity Cards UI Part Metadata Item JSON
     {"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:

    JSON Array From getMetaData()
    [	{"id":"1","name":"Persons Default", ..., 
    	 "uiParts":
    		[	{"id":"1","entityCardId":"1", ...}
    		]
    	},
    	{"id":"2","name":"Companies Default", ..., 
    	 "uiParts":
    		[	{"id":"2","entityCardId":"2", ...}
    		]
    	},
    	...
    ]

    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:

    Synchronous Use of getMetaData()
    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.

Copyright © 2014-2019 Aptify - Confidential and Proprietary