Showing posts with label Parameter in Pega. Show all posts
Showing posts with label Parameter in Pega. Show all posts

Thursday, 8 August 2019

Index in Pega (Append, Current, Insert, Last, Prepend)


Index in Pega (Append, Current, Insert, Last, Prepend)


Hi Friends, Today we will see how to use Index in Pega.

To Refer PDN Help click here

There are 5 indexes available.

  1. Append
  2. Current
  3. Insert
  4. Last 
  5. Prepend

Append: (Format: PageList.pxResults(<Append>).PropertyName)

     To add an element to Page List or Value List at the end we will use this index. For Example, We have a page list with 5 Pages if we want to add a new page then we will use this index to append a new page .

In the activity created a new page List named TempList .


Each Page of TempList page list refers to Class "TGB-HRApps-Data-Courses".


Save and executed the activity A Page List is created in Clipboard without any pages in it.


In 2nd Step Property Set added logic to append a new page to page list. In that page ID Property we are setting to value 1.


After Executed the activity a new page is appended in the page list so 1st Page created with values.


Modified Step to Append 3 Pages one after one.

After Executed activity , In Clipboard you can see 3 pages created one after one.


Hope understand about Append Index. Lets see Last Index.

Last: (Format: PageList.pxResults(<LAST>).PropertyName)

If We want to add any property values in Last Page, then we  have to use this index.


After Execute activity you can see Description is added in Last Page(3).


Hope understand about Last Index. Lets see Insert Index.

Insert: (Format: PageList.pxResults(<INSERT>3).PropertyName)

We are use this index to add a page at a particular Index. For example if we want to add a page in 4th Place then we have to give like (<Insert>4)

In the below screenshot we are adding a page in 2nd index , In that page we are setting Description as Chemistry.

After Execute the activity, We can see 2nd page is created with Description Chemistry.



Hope understand about Insert Index. Lets see Prepend Index.


Prepend: (Format: PageList.pxResults(<Prepend>).PropertyName)

Use this index to Add a page in First Index. For example, if you want to add a page in first index of the page list then we have to use this index.

Add a step to Add a page in first index with description Physics


A New Page prepended at 1st index with Description Physics



Hope understand about Prepend Index. Lets see Current Index.

Current: (Format: PageList.pxResults(<Current>).PropertyName)


Current functionality is same as i in for Loop ( for(i=0;i<5;i++) , We can refer Current Loop Page property using this index.

If you see below image we are Copying current loop ID value to Param.ID.
 
So When 1st Loop execute the expression will be TempList.pxResults(1).ID
     When 2nd Loop execute the expression will be TempList.pxResults(2).ID
     When 3rd Loop execute the expression will be TempList.pxResults(3).ID
     etc,



Hope understand about all index. Comment me in case of any doubts friends😊

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.