Error on getDataPage method JS API

I am trying to load data page contents using JS API in js text file rule. But below error appears on browser console;

Uncaught TypeError: Cannot read properties of undefined (reading ‘ui’)

What causes this error ? I am using exactly the same syntax as described in JS API docs.

On browser console, I see pega.api.ui.actions.getDataPage is already defined.

pega.api.ui.actions.getDataPage.png

@EngincanY

Hi, did you manage to find the cause of this issue? We are facing the exact same error with different JS API functions.

We are using 8.6.0.

Thanks

​​​​​​​

@Riadh Hi, I had created SR for this and resolved the issue.

You need to register each data page that you want to retrieve using getDataPage API as below just before calling getDataPage method.

ClipboardPage UIActionPage = ((PegaAPI) tools).getUIEngine().getUIActionPage("runActivity");
ClipboardPage actionAPI = UIActionPage.getPage("pyActionAPI");

actionAPI.putString("pyActivity", "pzGetDataPageJSON");
ClipboardPage activityParam = actionAPI.getProperty("pyActivityParams").getPageValue(ClipboardProperty.LIST_APPEND);

activityParam.putString("pyName", "pyDataPageName");
activityParam.putString("pyValue", "D_pxGetApplicationSettingValue");
((PegaAPI) tools).getUIEngine().getUIAction(UIActionPage).register();

activityParam.putString("pyName", "pyDataPageName");
activityParam.putString("pyValue", "D_PortalContextGlobal");
((PegaAPI) tools).getUIEngine().getUIAction(UIActionPage).register();
     
UIActionPage.removeFromClipboard();