Thursday 21 March 2019

How to call activity from Java Step in pega

How to call activity from Java Step in pega


Hi all, In pega we are using Java code when some functionality is not achievable by pega.

We all know how to call an activity from an activity. In this post we will see how to call an activity from Java code.

I created an activity named JavaPractice. In this activity I used a Java Step


HashStringMap map = new HashStringMap();                   //  Creating Hash Map
map.put("pyActivityName","TestJavaActivity");     //  Adding Activity in HashMap
map.put("pyClassName","");  //   Set ClassName of activity

ParameterPage p = new ParameterPage();                           // Creating New Parameter Page
  
p.put("ParameterOne","ParamValue1");                            // Set ParameterOne = ParamValue1
p.put("ParameterOne","ParamValue1");                           // Set ParameterTwo = ParamValue2

ClipboardPage pg = tools.createPage("TGB-HRApps-Work",null);  // Create clipboard page

tools.doActivity(map,pg,p);   // doActivity  (Hashmap , Clipboard Page, Parameter Page)

In the above Code we are Creating a HashMap in that we are setting the activity name to call and its class name. then we are creating Parameter Page named P in this Page we added two parameter named ParameterOne and ParameterTwo then created a Clipboard Page named pg and then I passed HashMap, ParameterPage, Clipboard Page as argument for doActivity function



So our expectation will be on running this activity it should call "TestJavaActivity"

I configured TestJavaActivity to get the Parameter that we passed in the above java code.



Let's trace the activity JavaPractice and check whether TestJavaActivity is called or not.

I run the activity and it get runned successfully and the activity got traced.

In the Below picture you can see in step 1 you can see the  Name as JavaPractice and in Step 3 you can see TestJavaActivity  so our Java code works as expected.



In the below picture we can see the parameter value is copied to RetrievedParameterOne and RetrievedParameterTwo.


Thank you. Hope you understand this post.

No comments:

Post a Comment