Question
Royal Cyber Inc
US
Last activity: 8 Jul 2019 12:06 EDT
get property value from pyWorkPage from the running thread.
I have to get the property data from pyWorkPage from the running thread on clipboard, i.e. F-114 etc using an activity. I have used many methods but unable to get the F-114 thread data, I have tried using tools.findPage("pagename"), from publicAPI, and also I have treid using requester as "tools.getThread().getRequestor().getThread("F-114");" in the java block in activity, and also I have tried this : "tools.getRequestor().getThread("<F-114>").getPage(<pyWorkPage>").getString(".pyStatusMessage")"
But none of these worked for me, Kindly help me out in this regard, thank you.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
FR
Hello,
So you are currently on another thread? Or on the same one? Maybe you can store the information at requestor level to be accessible on all threads.
Royal Cyber Inc
US
I have one running application instance with the id F-114, on clipboard I can see the data in this instance in pyWorkPage on clipboard. On Clipboard I can see two threads, one with the name "STANDARD" and another with the name "F-114", I need to get property values from pyWorkpage of "F-114" thread from Clipboard. Since I am new to pega, So I don't have idea about saving the information on requester level, Kindly guide in brief. Thank you.
Royal Cyber Inc
US
Any update on this? Kindly help me out, as I am stuck in this issue... :(
Royal Cyber
PK
"tools.getRequestor().getThread("<F-114>").getPage(<pyWorkPage>").getString(".pyStatusMessage")"
when I am going to execute code it gives me error of "page not found"
Note : by using below code I am easily getting STANDARD thread properties/values
"tools.getThread().getRequestor().getThread("STANDARD");"
"tools.getRequestor().getThread("<STANDARD").getPage(<pyWorkPage>").getString(".pyStatusMessage")"
able to get STANDARD thread properties unable to get property values other than STANDARD thread like my F-114 thread.
Royal Cyber Inc
US
Any update on this? Kindly help me out, as I am stuck in this issue... :(
Royal Cyber
PK
Hi Pega Support Team
Any update on this issue I am also stucked here not getting any response kindly help us give us proper support
Pegasystems Inc.
GB
Hi
i am not sure if you used the right thread name "<F-114>".
"tools.getRequestor().getThread("<F-114>").getPage(<pyWorkPage>").getString(".pyStatusMessage")"
in an activity java code please run the following line and check for the available thread names. The return type of getThreadNames() method is a Set.
oLog.infoForced("Thread Names=>"+tools.getRequestor().getThreadNames());
look at the output and see if the "F-114" shows up. for ex, when i run the above code locally, i see following output
Thread Names=>[OpenPortal, TABTHREAD0, PS1__TABTHREAD0, STANDARD]
later you could use the expected name in "tools.getThread().getRequestor().getThread("...");"
hope this helps
Royal Cyber Inc
US
First of All, Thank you so much for you response.
I have checked it, but oLog.infoForced("Thread Names=>"+tools.getRequestor().getThreadNames());
This is giving only STANDARD thread as output, although I have running instance F-114 and I can also see this on Clipboard.
I have tried the above, but it is responding the 500 error, as it can't get F-114. what should I do now?
Your help should be highly appreciated.
thank you.
regards,
Pegasystems Inc.
US
Hello,
I just tried tools.getRequestor().getThread("TABTHREAD1").getPage("pyWorkPage").getIfPresent(".pyStatusWork").getStringValue(); and it worked for me. The trick is, the name for getThread() is the internal name, so not "F-114". I had to find that by going to Data Pages > Requestor > D_ThreadList.pxResults() in the clipboard viewer and walk through to find the page with a matching pyLabel for my item ID and then use the pyID field for the internal name.
But to circle back, I think this is probably the wrong approach. As you can see, you can get there but it's going to be convoluted. Why are you trying to manipulate data in a thread that isn't your active thread to begin with? From within your current thread, a data transform can get to your data directly through page/property referencing. Same for activities. You should rarely ever need to drop into java when working in Pega and on those occasions, you should have a very specific usecase that you could articulate here, and likely one of us could help you find an easier way.
Thanks,
Mike
Royal Cyber Inc
US
Thank you So much for your kind response Mike,
Unfortunately! This is still not working for me...
I have tried using this:
String s = tools.getRequestor().getThread("TABTHREAD1").getPage("pyWorkPage").getString(".pyStatusMessage");
and Also this:
String ss = tools.getRequestor().getThread("TABTHREAD1").getPage("pyWorkPage").getIfPresent(".pyStatusMessage").getStringValue();
As I checked in clipboard (Screenshot attached below) that my thread with label F-117 has the pyID = TABTHREAD1, So I tried your given approach, but its not working for me yet, I am getting the page not found error.. :(
Kindly guide me accordingly to get out of it. ... :(
Thank you. :)
Pegasystems Inc.
US
Where are you getting the page not found error? With the code above, I would expect (and in fact worked through a number of) null pointers. Are you sure the error is coming out of your java code?
Again, though, I'd take a big step back. I'm fairly certain that doing what you are trying to do from java is probably the wrong way to go. What is the business problem you are trying to solve? What are you doing at run time where you can't get your process to access data on another thread? Why are you trying to access that data? Odds are, if you configure things correctly, in the right context, you should be able to do what you need from a data transform without struggling to get custom java to work.
Thanks,
Mike
Royal Cyber Inc
US
Let me explain my problem thoroughly in details...
I have to get values from clipboard (Running thread i.e. F-117) through the Rest API.
The properties may vary at later time, but for now I have to get pyStatusValue and pyStatusMessage Values from the running thread from clipboard through Rest API (See Screenshot Attached Below).
So I am trying to do the above case as I made an Activity named: "StatusChk" and in that Activity I have a Java Step in which I have just 2 lines of java code Given in the below attached Screenshot.
I am calling that Activity in Rest API Get Method, REst API Name: "CheckStats" (Screen Shot attached below).
and then when I Test/Run the Rest API, It couldn't find the Page (Thread "F-117") and it says page Not found for F-117, but it is working fine for Standard Thread... (Screenshot Attached Below)
Even though I can do all the above scenario and can get any of the property value through this method from STANDARD Thread, But Can't get the values from Thread F-117 (Running thread. ).
If there is any alternative way of achieving this, kindly explain it to me in very brief (Scratch), as I am new to Pega, and I have hardly 4 months of working experience on Pega.
Thank you in advance.
Regards,
Amjad Hussain.
Pegasystems Inc.
US
Amjad,
I think it's starting to make sense now. REST APIs are not my area of expertise, so I may have a few details wrong, but I believe that it's going to be running in its own requestor. That means it has no access to your clipboard. I think you would need to pass the key to the item and then open it up from the database to get access to that data. My guess is the REST API runs in the "STANDARD" thread, but if you were to log data from that thread, you would find that it has different data than your "STANDARD" thread. The good news, it will all be in a single thread and easy to access if your activity does something like an Obj-Open-By-Handle.
Good luck!
Mike