Question
IP Australia
AU
Last activity: 1 Nov 2017 3:05 EDT
How to get Current workpage pyID using java function in Offline enabled custom mobile App
Hi,
I am trying to get the current workpage pyID value in a function, but I am not able to get the value. Any thoughts?
String Id=tools.findPage("pyWorkPage").getProperty("pyID").toString();
Rest of the function java code is working, but the above step is not working.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
IP Australia
AU
we are able to solve the issue by converting the function code to javaScript and used below code to pass Id to proceed.
var ID = pega.ui.ClientCache.find("pyWorkPage").get("pyID").getValue()
Pegasystems Inc.
IN
Where/how are you executing this function?
Since you're in offline context, my best guess is you're using 'callActivity' action. callActivity works in its own context or at best in the context of unnamed page that is created with 'data' JSON object you pass with the action. In such cases, you need to pass 'pzInsKey' of workpage from client and open corresponding work object on server to access work properties. When adding callActivity action, you should be in work context on client and write something like -
var metadata = {
"action": "callActivity",
"activityName": "---",
"className": "---",
"parameters": [
---
]
};
var data = {
"insKey": pega.ui.ClientCache.find("pyWorkPage").get("pzInsKey").getValue()
}
Then, in your activity you access "insKey" with myStepPage.getString("insKey")
Or, you can pass insKey alongwith parameters in which case you can access it using Param.insKey
IP Australia
AU
Hi,
Thanks for the reply. I am not using call activity. I am using a section which has HTML code and in java script function I am calling function.
function send()
{
var obj='<%=pega.<java.lang.Void> resolveMethodCall("FunctionName--(PublicAPI)", "LibraryName", null,null, new Object[] { tools })%>';
FunctionName--(PublicAPI) is my function and I am trying to get pyID of the workpage in which the section is referenced.
Pegasystems Inc.
IN
You will not have workpage context on server in that case. One of the first phase for offline-enabled apps is 'packaging' which is done outside of work context or rather I should say it is done in 'Template workpage' context which doesn't have pyID. It may have other information which is case specific because template workpage is built by running pyDefault data transform.
You can have access to workpage id on client though using ClientCache APIs. And in that case you'll have to write Javascript equivalent of your Java function.
IP Australia
AU
I have tried to include client cache code in my HTML section function before calling my java function, but still it is not working.
function send()
{
var cc = pega.ui.ClientCache.find("pyWorkPage").get("pyID");
var obj='<%=pega.<java.lang.Void> resolveMethodCall("FunctionName--(PublicAPI)", "LibraryName", null,null, new Object[] { tools })%>';
Pegasystems Inc.
IN
You cannot have mix of both. ClientCache code is executed in client context. resolveMethodCall will be compiled on server and you wouldn't have workpage context at that time. You should convert your logic in Java function to equivalent JS code if you wish to run your send() function in current work context.
Accepted Solution
IP Australia
AU
we are able to solve the issue by converting the function code to javaScript and used below code to pass Id to proceed.
var ID = pega.ui.ClientCache.find("pyWorkPage").get("pyID").getValue()