Posted: 9 Sep 2020 19:44 EDT Last activity: 9 Nov 2020 15:54 EST
Execute Activity Rule in Java
I am trying to run a separate Activity rule in a Java function. I've tried using both tools.doaction() and tools.doactivity() Public API methods but both reset the current primary page which I believe is the normal behavior. Is it possible to avoid this reset and have then activity run as if I was calling it from another rule instead of the java code?
***Edited by Moderator Marissa to update Platform Capability tags****
To be clear, resetting the Primary Page is not the normal behavior; normal behaviour is for the Activity rule to apply its functionality on an already-resident Primary Page, handed over by the caller.
doActivity and doAction both take three parameters, one of which is the ClipboardPage java object of the page to be used as the Primary Page. The caller will typically know the clipboard reference to this page, and will need something like tools.findPage(...) to look this up and get the ClipboardPage reference to it. The syntax might be more intricate if the Activity's primary page needs to be an embedded page instead of a top-level page.
Whenever I'm looking to determine the Java code needed to emulate something that would be done from a rule-form, I stage it in the ruleform and use the "View Java" option from the Actions menu to observe what Java could accomplish what I need. Try it yourself, you'll be amazed what you learn.