Press "Enter" to skip to content

Activity methods on clipboard pages

65

Introduction

  • Every activity rule can contain  one or more steps.
  • Each step in an activity rule can contain a method.
  • Methods are implemented in Java.

Each method updates the pxMethodStatus property on the pxThread page.

pxMethodStatus values can be – Good, Warn or Fail

In this post, I am going to explain various methods related to clipboard pages.

Methods related to clipboard pages

1. Page-New

  • Obviously creates a new page in the clipboard memory.

When do we use this method?

  • Let me reframe the question. When will you create a new page?

Pages can hold single value properties and can be referred in another activities and sections. When a new process starts, we can create a new page and set all the required values in the page.

For example – When we need to browse some data from a DB table and populate in the grid section.

You can use Page-New to create a new page to hold the browse results.

Note: Always remember to provide the step page in the Page & Classes tab. Else you may get activity design time error.

What are the method parameters?

a) Data transform – You can specify a data transform rule and populate the new page with required values. Not a mandatory option.

b) PageList – Don’t get confuse with the name pagelist . You need to specify a value list property here to append the Page name to the last element in the value list property.

c) NewClass – You can specify a new class for the page. The class specified here takes priority over the class specified in pages & classes tab.

For testing purpose I created a new data transform -SetLabel to set the ‘pyLabel’ = “Knowledge sharing”

Let’s test the page-new method by providing all the parameters.

Run the activity. Check the clipboard.

  • You can see the pxObjClass = OIKGGB-MyKnowPega ( set from NewClass method parameter)
  • pyLabel = “knowledge sharing” ( Set from data transform)

  • You can see the Valuelist property is appended with value as Step page name ( page list method parameter)

What are the things to remember when you use Page-New method?

  • Always remember to mention step page in the page new method. If you forget to mention, then Page-New method clears the primary page of the activity.
  • Page-new can also be considered as removing a page and creating a fresh page.
  • Page name in the clipboard should always be unique. If a page with the same name already exists in the clipboard, then the Page-New method deletes the page and a new page in that same name.
  • You can use an API function in any step precondition to check if the page already available in the clipboard“@PageExists(“<Page Name>, tools)” – this returns either true or false.

2. Page-Remove

  • This method helps in removing any existing page.

When do we use this method?

  • Usually we use this method to remove the pages, which are not in use.

I get some weird example :D.

Creating a page implies, We are using  some space in JVM memory. It is always advisable, to maintain the JVM memory within limit. So obviously you need to clear out the unwanted pages.

  • You populated a page with required values, then you used the page and completed the process. Now you don’t need the page. You can remove it

What are the method parameters?

  • In the page array, you can add more than 1 page. This method helps in removing more than 1 page in a single step.

Let’s test it. Run the activity with 2 steps –  Page-New & Page-Remove method.

Check in the clipboard.

What are the things to remember when you use Page-Remove method?

  • In every activity, try to remove the unwanted pages in the last step
  • This method clears the page added in the step page field. If the step page is not specified, Page-Remove method removes only the pages specified in the method parameters page array (Never removes the primary page, when step page is blank)
  • If a page is not available in the clipboard, the step throws warning not error.

3. Page-Rename

  • This method helps in renaming any existing page in the clipboard.

When do we use this method?

  • There may some situation, where you need some particular data available in particular page.

For example –  You have an activity which can browse and get the results in a page ‘NewPage’, but you have an section mapped to page ‘RenamePage’. In such situation, you can just rename the page.

We hardly use this method

What are the method parameters?

You have a single mandatory field – PageNewName

  • You enter a new page name here.

Let’s test the Page-Rename method

Run the activity and check the clipboard. You can find the new page.

What are the things to remember when you use Page-Rename method?

  • This method can be used only for top level page. We cannot rename an embedded page.
  • If the new page already exists in the clipboard, then this method deletes the existing page and create a new page

4. Page-Copy

  • This method helps in copying the contents from an existing page (source) into any new or existing page (destination). It’s just copying

When do we use this method?

For example – You populated a page with certain values. If you need the same values in different page, then you can use this method to make a page copy.

Note: Unlike Page-Rename method, we will have both the source page and target page available in the clipboard.

What are the method parameters?

a) CopyFrom – You can specify the Source Page here. This is not mandatory. If blank, then the step page will be the source page.

b) CopyInto – Target page.

c) Data transform – You can make use of this data transform to add some additional properties in the target page.

Note: This data transform does not update existing values. Only adds new value.

d) PageList – This parameter is same as we saw in Page-New method.

Don’t get confuse with the name pagelist :). You need to specify a value list property here to append the Page name to the last element in the value list property.

Let’s test the Page-Copy method.

Step 1: I used a property-set method and populated PhoneNumber and pyLabel values.

Step 2: In the page-copy step I set the target page as “TempPage” and use a data transform to add additional properties.

I used the same data transform used for Page-New method; pyLabel = Knowledge Sharing

Run the activity and check in the clipboard.

You can see the TempPage is created and populated with all the values.

What are the things to remember when you use Page-Copy method?

  • It is not always mandatory for source page and target page to be available in the clipboard.
  • When you use data transform, data transform rule applies first followed by page copy values.

Simply saying, you cannot update the existing values using data transform.

  • If the destination page already exists in the clipboard, then the system deletes the old page and replace it with new values.

5. Page-Set-Messages

  • This method helps in adding message to the clipboard page.

We know that adding a message to a page or property, prevents the page from being saved into database.

When do we use this method?

  • Normally we use validate method to set the error message. You can also use other validation methods to set the error message.
  • In some situation, where you need to validate a single property ( no need for reusing in other areas), you can set the error message using Page-set-Messages.

What are the method parameters?

a) Page – You can provide the page name to which the error message will be added.

If left blank, then system checks step page. If step page too blank, then system adds the error message to activity primary page

b) Category – You can specify the field value category name. You use this option, when the message value is from field value rule.

c) Message – You can specify three options here

  • Message rule – You can directly entry a message rule
  • Field value rule – You can specify a field value rule.

Note: Field value and message rules both support localization.

  • Constant string – You can also specify some hardcoded string as error message.

Let’s test the Page-Set-Messages method.

Step 1: Add a Page-Set-Messages method.

Here I have selected the 2nd option to use the field value rule –FailedToOpenInstance.

Step 2: Run the activity and check in the clipboard.

You can see the error message added to clipboard.

What are the things to remember when you use Page-Set-Messages method?

  • You can use this method to add error message to primary page or any embedded page.

Note: Even if you add error message to any embedded page within pyWorkPage, you cannot commit the case into db.

  • You can use this method in flowaction post processing activity to prevent the page from committing to DB.
  • Once added in flowaction post processing activity, you will see the error message displayed in UI.

Add the activity in flow action post processing – remove the step page for page-set-messages, so that error set on primary page. In our case ‘pyWorkPage’.

6. Page-Clear-Messages

  • This method helps in removing the property and page level messages in the step page identified.

You need to use this method with care. This method clears out all the error messages we set before.

Note: This is exactly opposite to Page-Set-Messages.

When do we use this method?

  • There may be some situation, where you may need to clear all the error messages before committing to database.

Note: This is not the only way system clears the error messages. System use to clear the error messages before submitting the form to server.

Say for example – You are entering a form with invalid phone number. System throws error. Now again you enter a valid number and submit the form again. Here Pega clears the error message before submitting the form.

What are the method parameters?

Cool. No method parameters 🙂

Let’s test the method.

Step 1: Add a new step: Page-Clear-Messages below Page-Set-Messages.

Step 2: Trace open the rule and run the activity.

You can see the error message set in step 2 is cleared in step 3 🙂

What are the things to remember when you use Page-Clear-Messages method?

  • This method not only clears the page level messages, it also clears the property level messages.
  • Always use this method with care.

7. Page-Change-Class

  • This method helps in changing the class of an existing page.

I would say Page-Change-Class = Page remove + Page – New

In addition to changing the class, you can also update some properties in the step page using data transform rule.

When do we use this method?

  • When we need to save/commit any existing page to some different class, we can use this method.

This method just change the pxObjClass value alone.

You can also use data transform to update some values.

What are the method parameters?

a) ObjClassNew – You can specify a new class name for the page.

b) Data transform – You can use a data transform rule to update any values in the step page.

Keep – This is an interesting parameter 🙂

a) Keep – 0

Value already present in the step page are retained. Not overridden.

Eg: In step page, we have pyLabel =”Knowledge Sharing”. You cannot update pyLabel using data transform. You can just add new values from the data transform.

b) Keep – 1

This is the opposite to 0. Values already present in the clipboard can be overridden by values from data transform rule.

Let’s test it.

Step 1: Create a new page ‘ActivePage’ of class – TVS-TeslaVeh-Work-ServiceRequest

Step 2: Set some values – PhoneNumber = 1111111111

Step 3: Use Page-change class method and change the class to ‘TVS-TeslaVeh-Work-SRMain’

  • In the data transform, update phonenumber = ‘9999999999’.

Run the activity and check in the clipboard.

Remember, we set Keep =1. So phone number updated.

You can test by setting Keep = 0

So you will get a question here!

What do you mean by Keep = 2?

  • This is same as Keep=0 (retains value), with a restriction for Page list, value list and value groups.

Say, you have a pagelist property – PolicyList appended to WorkPage.

You need to change the WorkPage class and update the PolicyList property.

Let me explain it in tutorial. No words only action 😀

Step 1: Populate Active page with PolicyList page list property ( Assume 3 policylist pages)

Step 2: You need to update PolicyList with ActiveTargetPage.PolicyList values.

ActiveTargetPage – PolicyList(1) & PolicyList(2)

Step 3: Create a simple data transform and set PolicyList = ActiveTargetPage.PolicyList.

Step 4: In the page change class – Fist set Keep = 1 (Override).

Run the activity and check the clipboard.

You can see Policy list is overridden.

PolicyList(3) is removed; PolicyName = “HousePolicy”

b) Keep = 0 ( retain)

Run the activity and check the clipboard.

Check PolicyList(3)

You can see the values are retained.

c) Now Keep = 2

Run the activity and check the clipboard.

You can see the pagelist result count mismatch

  • ActivePage.Policy contains 3 pages.
  • ActiveTargetPage.PolicyList contain 2 pages.

So on updating, PolicyList(3) is updated with values from ActiveTargetPage.PolicyList(1)

You can see IsHomePolicy is copied to PolicyList(3).

In simple words, first element of the data transform list is used as the value for target list elements.

Same for value list & value group.

What are the things to remember when you use Page-Change-Class method?

  • Carefully set the Keep parameter, if you use data transform.
  • This is different from Page-Rename, where we change the page name not the class.

8. Page-Merge-Into

This method helps in merging the contents of two or more pages into one page.

When do we use this method?

  • When we want to bring the contents of two or more pages in a single page.

Page-Copy, copies the entire contents from source page to target page.

Page-Merge-Into, merges the contents from source page to target page with Keep parameters.

Remember keep parameter, we use for Page-Change-Class

What are the method parameters?

a) MergeFromList – You can specify more than one page using these fields. The order is significant.

Pages merge in the order they are specified in the MergeFromList array.

b) Keep – It can accepts 0, 1 or 2

Keep = 0

Contents in the source page is retained. Only new properties from target pages can be merged.

Keep = 1

Contents in the source page can be overridden. Properties from target page can update the properties in the source page.

Keep = 2

This is same as 0 with exception for PageList, ValueList and ValueGroup

You can refer the Keep parameter explanation for Page-Change-Class method. Same applies here 🙂

Let’s test the Page-Merge-Into method.

Step 1: Populate 2 source pages – TempPage1 & TempPage2 with pyLabel values.

Step 2: Populate a target page – ActivePage with pyLabel value.

Step 3: Add Page-Merge-Into step to merge the 2 source pages into target page – Active Page

Step 4: Keep = 0. Run the activity and check in the clipboard.

You can see the pyLabel value in target page is retained.

Keep =1, Run the activity and check the clipboard.

Keep = 2

If the target page list contain more elements than the source page list,

TargetPage.PolicyList – contains PolicyList(1), PolicyList(2)

SourcePage.PolicyList – Contains only PolicyList(1).

In this case, when we want to merge the page, then SourcePage.PolicyList(1) will be the source for both the elements PolicyList(1) & PolicyList(2) in TargetPage.

You can refer the Keep =2 example in Page-Change-Class method J

What are the things to remember when you use Page-Rename method?

  • Important point is this method cannot be used steps within iteration.
  • If the target page is not found, system creates a new page and merge the source pages. If the source pages are not found in the clipboard, system just ignores the source pages.
  • The order is some important in MergeFromList array.

9. Page-Validate

  • This method helps in validating all the properties within the step page

A property’s value can be restricted by using some validation in the property form.

Eg – Property mode, table type, Max length, edit validate rule.

  • Normally this validation occurs when you set value for the property. So why we need this method then?!

In some situation, the properties can be updated by java or some other means. In such case we can use Page-Validate method to validate all properties.

Note: Page-Validate is very expensive, since it validates all the properties within the page.

What are the method parameters?

You can see the method contains a single parameter – WithErrors

WithErrors –

Imagine the page contains error prior to this step. So if you select WithErrors, then the Page-Validate method executes and validates the properties again.

If not selected, then the method ends.

Note: You can leave this cleared, since you no need to validate a error pageJ

What are the things to remember when you use Page-Validate method?

  • We use this very rarely. Keep in mind how expensive it will be, If there about 1000 proeprties within the page.
  • Prefer using Obj-Validate method to validates properties on a page
  • When a property fails validation an error message is add to the page.

 

These are the main activity methods that involve clipboard pages.

We will see a post on Obj vs RDB methods very soon 🙂

 

 

  1. vikram vikram

    Hi Prem, How to debug an activity when there is an error with the help of tracer? Please show where to find the errors in activity

    • Premkumar G Premkumar G

      Hi Vikram,
      Tracer is a debugging tool, used to capture the exceptions.
      When there is some error, the tracer steps will show you. You can click on the error step page, to identify the error message.
      You can also break the tracer run when there is some exception condition

      Settings -> break condition -> you can choose exception/fail/warn status to pause the tracer.

  2. Ramakrishna Ramakrishna

    You are awesome Prem. Can you please share looping in activities as well.

    • Premkumar G Premkumar G

      Thank you so much, Ramakrishna. 🙂
      Yeah I’ll post about them soon. 🙂

  3. Pavan Pavan

    Hi Prem,

    Very Good explanation,Thanq so much for sharing knowlodge.

    Can you please explain workbasket,workgroup and worklist.

    Thanks.

    • Premkumar G Premkumar G

      Sure Pavan. I will add this in my backlog 🙂

  4. satish satish

    can you please post on case management

    • Premkumar G Premkumar G

      Sure sathish. I will plan it very soon 🙂

  5. Keerthana Keerthana

    Hi PremKumar,

    The data which is shared in this blog is much useful for every Pega Beginner(especially to those who wants to learn in V7.2+ version). I’ve handson on V6.3 and I’m doing handson on V7.2 by rferring to the concepts shared by you. Please keep posting each and every concept. I will recommend even to my colleagues and friends. 🙂

  6. prateek prateek

    thanks prem..

    • Premkumar G Premkumar G

      You are welcome, Prateek. 🙂

  7. Navpreet Navpreet

    Hi Thanks alot for the Tutorials its really Help us lot,Can you please sometime we see two Page error message in the top and bottom of Screen why it is do so and what is the way to resolve that probelm.

    • Premkumar G Premkumar G

      Hi Navpreet,

      Thanks for you comment 🙂

      Step 1: Do a live UI and find the harness
      Step 2: Open the harness rule and go to 2nd tab – display options
      Step 3: You will see a field ‘Form-Level-Error’ under error section
      Default – error will be displayed in top and bottom
      Top of harness – Only at the top
      configurable section – You can display in your own section

      Pega, set the settings to ‘Default’. just change it 🙂

  8. Surya.D Surya.D

    Hi Prem,

    Your posts are very good and very explanatory, could you please post some thing on exceptional handling andcase management.

    • Premkumar G Premkumar G

      Hi Surya,

      Thank you so much. 🙂
      Yeah I’ll post about them soon. Stay tuned. 🙂

  9. Sowmya Sowmya

    Hi Prem,

    Nice explanation ,Could you please explain about SMA, Dynamic system settings etc.

    Regards,
    Sowmya

    • Premkumar G Premkumar G

      Hi Sowmya, noted. I will try to make a post on it soon 🙂

  10. kiran kiran

    Great read.
    It would be of great help if you can post a topic about migration?

    Thanks,
    Kiran

    • Premkumar G Premkumar G

      Noted. i will try to make it soon

  11. shivakumar.m.hugar shivakumar.m.hugar

    Good explanation Prema Thanks

    • Premkumar G Premkumar G

      Thank you, Shivakumar. 🙂
      You are welcome.

  12. Sandeep Mahajan Sandeep Mahajan

    Premkumar Sir, request you to cover topic that covers connection between PEGA to Mainframe, to read DB2 database.

    • Premkumar G Premkumar G

      Yeah Sandeep. Will cover them soon. Stay tuned. 🙂

  13. Divakar.M Divakar.M

    Hi Prem ,

    Very useful … thanks

    • Premkumar G Premkumar G

      Hi Divakar,

      Glad that you like it. 🙂
      You are welcome.

  14. Haranadha Reddy Haranadha Reddy

    Thank a million Prem for the knowledge you are sharing

    • Premkumar G Premkumar G

      You are most welcome, Haranadha Reddy. 🙂

  15. Pavani Pavani

    Fantastic job . I seriously think how do you manage time to write this blog😆😆

    • Premkumar G Premkumar G

      Thank you so much for your appreciation, Pavani. 🙂

  16. Mahesh Mahesh

    Hi Prem,
    It was awsome.

    also kindly help with OBJ-Browse, OBJ-save facility.

    Thank very much

    Mahesh

  17. pradeep pradeep

    Hi prem,
    when can we expect obj-methods, and rdb ?please post ASAP.
    and can you please explain the concept updating a flow

    • Premkumar G Premkumar G

      Hi Pradeep, my next post will be on SOAP. After that I will make a post on Obj RDB methods

  18. prathap prathap

    Prem in Page-New Method
    PageNewDT:Blob-LoanApp-work-prathap
    NewClass:Blob-LoanApp-work-Home

    for this context its not working ,i think here we are missing context whether they can be in patten or Direct inhiritance,if you provide this information,it will be helpful for beginners.

  19. ravikumar ravikumar

    Good explanation. Could you please make any videos about pega. then it’ll going to be very easy.

    • Premkumar G Premkumar G

      Thank you so much, Ravikumar. 🙂
      Yeah, many people have suggested this, Ravi. I’ve also thought about it. I will try to implement that idea soon. 🙂 Thank you. 🙂

  20. Rupesh Rupesh

    Hi Prem,

    Every good explaination.
    Thanks for it .

    when can we except the post on case management and report defination . waiting for it.

    Thanks
    Rupesh M

    • Premkumar G Premkumar G

      Hi Rupesh,

      Thank you so much. And you are most welcome. 🙂

      I’ll post about them soon. Stay tuned.

      Regards,
      Premkumar G

  21. Srikanth Srikanth

    Hi prem,

    In a Page-New method, For PageList we have to create property right(what is property type for that I am getting error line “Specified Property is not defined as a string list: Invalid Value for page list field passed to Page-new”.

    • Premkumar G Premkumar G

      Hi srikanth,
      Don’t confuse with the name. It is actually a value list property. Please go through my post again. You will understand 🙂

  22. Naveen Kumar Naveen Kumar

    Thank you PremKumar, Worth reading this Article, helped me a lot. Good Explanation.

    • Premkumar G Premkumar G

      You are most welcome, Naveen. 🙂
      Glad to hear that you liked it. 🙂
      Thank you so much. 🙂

  23. swapna swapna

    Hi Prem,
    I am unable to change the class by specifying i in the ObjClassNew. Pl can u explain how to do it.

    • Premkumar G Premkumar G

      Hi swapna,
      You are using Page-Change-Class method right?!. It should change the class to the parameter you specify in ObjClassNew.

  24. Pradeep Pradeep

    Hi Prem,

    Can you please tell us difference between Error Handling and Exception Handling with scenarios

  25. ravikumar ravikumar

    Hi PremKumar,
    Could you please explain about looping in activites and as well as in data transforms..

  26. slyfox slyfox

    Hello!
    Thank for great explanation!
    Can you please write an article about a Top/Parent/Primary pages usage?

  27. Gowdhami D Gowdhami D

    Hi Prem,

    Thank you for the sharing:-).

    • Premkumar G Premkumar G

      Hi Gowdhami,

      You are welcome. 🙂

  28. shilpa shilpa

    Hi Prem,

    Thanks for sharing your knowledge,Can you please explain the looping scenarios of pagelists.

  29. Sushma Sushma

    Hi Prem,

    Doing a great job!!!
    Is it possible to share more details about activity in your post?…For instance the activity usage…That would be quite helpful too 🙂

  30. Vijeta Vijeta

    I am getting the date format is M/DD/YYYY instead of MM/DD/YYYY.what settings do I need to do in the property to display it correctly?

  31. PegaLearner PegaLearner

    Can you please explain the different logging levels and their meaning in ‘Log-Message’ method ?

  32. Divya Divya

    Nice explanation bro.
    Keep up the great work..

    • Premkumar G Premkumar G

      Thank you so much, Divya. 🙂
      I will. 🙂

  33. SivaJyothi SivaJyothi

    Prem Can you make a Separate post on How to Use API Functions in Pega with Explaining some of the most common used Functions??

  34. sanjeeb sanjeeb

    hi prem….what i observe in page remove is ..lets say page hasn’t been created so far and user trying to remove it by providing a dummy step page name , the activity executes that step on primary page context without throwing a warning….

  35. Anvesh Anvesh

    Good Explanation. Can you please share looping in activities as well.

  36. Surya Surya

    Hi Prem,
    I want to limit the use of a particular coupon number which i was created as a property.
    If limit is entered as 10 then after 10 members used the coupon it should be limited and at the end of 10th user it should show the coupon is invalid for the 11th user, who is trying to use the coupon by entering the coupon name.
    How can i do this ??

  37. Vinod Vinod

    Hey Prem,

    Awesome explanations on all the topics ! You made to look pega easy for beginners 🙂
    Please continue to do the great job (Y)

    Meanwhile, I have a silly question- Can we expect any return output values from called activity to the calling activity or class?

    Appreciate your response!

    Thanks
    Vinod

  38. A Banerjee A Banerjee

    Hi Prem,
    Thank you very much for your post. I’ve one confusion related to step page of activity. When and where do we use property names (embedded page) as step page ?
    A Banerjee

  39. DINDIPALLAVI DINDIPALLAVI

    HI Premkumar
    The Aritcle has helped me a lot. Thank you. But if possible can you share me whole article please it will be so helpful.

  40. Priya Priya

    Please do a post on looping in Pega that would be really helpful

  41. Monty Monty

    Brilliant explanation. Keep up the good work.

    Can you please also provide details about “Types of Activities in Pega”?
    Thanks in advance.

  42. Kakollu Kakollu

    In page copy does source and destination pages belong to same class?

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!