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.
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.
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.
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. ... :(
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.
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.