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😊

12 comments:

  1. Article is very interesting & detailed.Thank you

    ReplyDelete
  2. Your article was pretty clear for freshers like me. I want to ask that can i use integer property after .IntProp

    ReplyDelete
  3. Replies
    1. Yes, we can use.Refer below pega help for more clear understanding.

      https://community.pega.com/sites/default/files/help_v73/designer%20studio/expressionbuilder/ref_refaggregateprop_symbolic.htm

      Delete
  4. Hi Bro
    Can you please explain with one real time scenarios so that we can more clear

    ReplyDelete
  5. The article explains the scenarios very well with illustrative examples. Thanks Bharathan.

    ReplyDelete
  6. i want to update particular column of a table of pagelist, the updation should take place date-wise.Suppose in a pagelist their is some quantity entered by users choice and it will be consumed datewise , how to implement this.

    ReplyDelete
    Replies
    1. Sorry, I cant able to understand clearly Rohit.

      Do we need to arrange pages in pagelist by date?

      Delete
  7. If we want to KNOW the current index while doing 'For each page in', how do we do that??
    Like i want to run a DT only for the 4th index while running 'For each page in'
    How do i do that?

    ReplyDelete
    Replies
    1. Param.pyForEachCount will have the cutrent index value.

      Delete
  8. Is there any way we can get the last before value.(consider we dont know how many records are present)
    I tried with ( -1), but getting error.

    ReplyDelete