getModuleByClassId(classId: Number);
classId. Unit class identifier.
The getModuleByClassId method returns unit settings by identifier of its class.
The method returns the same value as the PP.App.getActiveModule method.
Executing the example requires that the Foresight Analytics Platform web application is opened. The scenario specified below must be started in the browser console.
Get code and names of the five most recently opened repository objects, and type of the unit where these objects are used:
// Callback function to determine list of recently opened documents var onGetRecentDocuments = function (sender, args) { for (var i = 0; i < args.Descriptors.length; i++) { // Get description of recently opened documents var descr = args.Descriptors[i]; // Get object with unit settings var module = PP.App.getModuleByClassId(descr.getClass()); if (module) { console.log("Unit: " + module.Data + ", " + descr.getKey() + ": " + PP.String.escapeHTML(descr.getName())); } } };
After executing the example the browser console displays code and name for the five most recently opened repository objects, and type of the unit where these objects are used:
Unit: 3, 109: GRP comparison by regions
Unit: 8, 1824: Indicators
Unit: 8, 1646: Countries
Unit: 8, 1830: Units
Unit: 8, 1829: Measures
See also: