Press "Enter" to skip to content

Activity methods on clipboard properties

8

Introduction

In this post, we will see more in details about activity methods on clipboard properties

This post will be the continuation of my previous post.

http://myknowpega.com/2017/07/10/activity-methods-on-clipboard-pages/

Here I will be concentrating on the methods involve in updating clipboard properties.

  • We know in Pega, properties holds all piece of data. It can be stored in temporary memory or can be persisted in database.

Throughout this post, we will see how we update properties using activity methods.

Let’s straight away jump into the first method.

  1. Property-set
  • This is very simple method, helps in setting property value on a clipboard page.

When do we use this method?

  • We, will use this more often, whenever we need to set a new value to a property or to update any existing property.

What are the method parameters?

a) PropertiesName – You can set the target value property in the left hand side

b) PropertiesValue – You can specify the source property value here. You can also use some constants. In the below example, you see “Pega Knowledge Sharing”.

Now, run the activity and check in the clipboard.

You see, pyLabel is populated as hardcoded value “Pega Knowledge Sharing” and pyNote is populated from pyLabel.

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

  • You can specify the expressions in the PropertiesValue field. The system evaluates the expression and sets the value to PropertiesName.
  • You can use Property-Set to set other property types too.

Page, Page list & Page group can be set to another Page, Page list & Page group properties directly.

But, you cannot set one property type to another property type.

  • You can use PropertyExists() function to check if the property is already available in the clipboard.
  • A property can be restricted to certain values or some other restrictions in the property form.

If you try to set values to such properties, validation occurs and thrown exception if restriction is violated.

Step 1:  Create a  property Gender with local list values – Male & Female.

Step 2: in the activity, set the Gender value to ‘M’ not “Male’.

Step 3: Run the activity & check in the clipboard.

You can see the error set on clipboard page.

Note: We cannot commit a page containing errors. Handle it with care, when you try updating such properties at t he backend.

2. Property-Remove

  • This method used to delete a property and its property values from the clipboard page.

When do we use this method?

  • We will use this method, when we want to remove the property from the clipboard.

What are the method parameters?

Property – This is an array list. You can specify more than one properties here.

This method removes the properties specified from the step page.

Let’s check it.

Step 1: Create a test activity and use property-set method to populate ‘pyLabel’ & ‘pyNote’ properties.

Step 2: Use property-remove method, to remove the pyNote property.

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

You will see pyNote property is removed.

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

  • In addition to single value properties, you can also remove the aggregate properties like page, page list & page group
  • If you want to remove the properties other than in the step page, you can use <Page Name>.<Property value> in the array.

3. Property-set-Messages

  • This method helps in adding a message to a property.

When do we use this method?

  • Normally we use the Obj-Validate method, to set the error message on individual properties in the
  • In some situation, you need to validate a single property and set the error message associated with the property.

What are the method parameters?

a) Message – You can specify three options here.

  • Message rule – You can directly enter a message rule
  • Field value rule – You can specify a field value rule containing the error message.

Note: Field value & Message both supports localization

  • Constant string – You can also specify some hard-coded string as error message.

b) Field – You can specify the property name to which you will set the error message.

c) Category – You can specify the field value category name here. (Field value rule key part). You can use this option only when the message is a local value rule. This is not mandatory.

When you provide some hard-coded constant string as Message, then we Category should be null.

Let’s test the method.

Step 1: Create a new test activity

Step 2: Add a Property-Set-Messages step to set the error message associated with the property.

Here, we have use a page list property – DemoPageList to set the error message.

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

You can see the step page is added with error.

Step 4: Let’s try something different. Set error on DemoPageList(1).Gender

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

You will see again page is populated with error message.

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

  • The message is added to the step page containing property.
  • Associating the message using property-set-message, will not cause the message to appear to the end user UI.

4. Property-Validate method

This method helps in validating properties against certain requirements.

When do we use this method?

  • Maximum you should be using the Obj-Validate method to validate properties.

For more info on validation rules, please follow the below post.

What are the validation rules in Pega?

Validate rule supports re usability and can be used in many places like activity and flow actions.

In certain cases, you need to validate particular property only in a single activity ( no reusable scope), you can use Property – Validate method.

  • Validation is performed by an edit validate rule
  • We can make sure that property is not null, else we can add message

What are the method parameters?

a) PropertyName – Enter the property name to be validated. You can use the array and enter multiple properties in the array.

b) ValidateAs – You can use two options here.

  • Edit Validate rule – Specify an edit validate rule to validate against the property.
  • If left blank – Edit validate rule specified in the property form.

c) Continue – When you specified more than one property in the array, you can continue validation even though the previous property fails validation.

d) Default – You can also specify a default value.

e) Required – You can validate this field as mandatory – not null.

If the property value is null, then the default error message

“This field may not be blank” will set on the clipboard.

f) ErrorMessage – You can specify a text string error message to be added, when the validation fails.

g) OnlyIfChanged – It is not used. You can leave it cleared.

Now let’s test it 🙂

Step 1: Create a test activity and a property – EmailAddress.

Step 2: Add a step to do Property-set. Set invalid address ( No ‘@’ and ‘.com’ characters)

Step 3: Add a new step Property-Validate and specify the parameters value as shown below.

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

You can see the custom error message set.

You can try testing on your own – Required & Default values 😉

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

  • System validates the property one by one. If continue is  selected, system validates all properties and adds the error message to clipboard page.
  • Prefer using Obj-Validate rule 🙂

5. Property-Seek-Value method

Let’s refresh the backward chaining.

Cost A + Cost B = Cost C

Here whenever we refer the Cost C value, system goes backward to compute the values for Cost A & Cost B. Once the values are computed, then the Cost C will be evaluated from

Cost C = Cost A + Cost B

Here Cost C refers to ‘Goal property

Before testing Property-seek-Value method, create 3 Integer properties and create a declare expression rule on Product C

For more info on Declare expressions and backward, please visit the below link!!

How to configure declare expression in Pega

Step 1: Create 3 Integer properties.

Step 2: Create a backward chaining declare expression rule.

In the change tracking – remember to check ‘Whenever used’ for backward chaining

When do we use this method?

  • We use this method to re-compute the value of the goal property, based on backward chaining declare expression rule.

Now, Imagine you are filling an online employment application form.

When you select any previous experience = “Yes”, then you may be populated with experience details.

This is kind of backward chaining.

  • Please check with ‘VerifyProperty’ & VerifyPropertyWithListing OOTB flowactions to provide the users with a popup to enter those values.
  • You can also check ‘VerifyProperty’ activity. It accepts Goal property as input parameter and use Property-Seek-Value method.

What are the method parameters?

a) GoalProperty – You can specify the property, we need to compute. This will be target property of the declare expression rule. Eg – CostC

b) Always Recompute –

There may be some situation , where CostC value is already available in the clipboard.

  •  If we select ‘AlwaysRecompute’ to true – then CostC is computed always.
  • If ‘AlwaysRecompue’ is false – then value specified in the declare expression takes precedence.

c) AlwaysForwardChain – You can leave this cleared

d) Missing reference property – You can specify any property or parameter here to hold which property is missing ( Cost A or Cost B) to compute Goal property ( Cost C)

Let’s test the method.

Step 1: Create a new test activity.

I assume, you have created the 3 new properties and declare expression rule on CostC

Step 2: Add a step and use Property-Seek-Value method.

Step 3: For testing add a Show-Page – ActivePage

Step 4: Run the activity.

You can see pyLabel holds the missing property – ActivePage.CostA

Step 5: Now set the CostA & CostB value in the ActivePage.

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

You can also check the CostC value

CostC = CostA + CostB

🙂

What are the things to remember when you use Property-Seek-Value method?

  • Backward chaining is always an expensive process in performance ( Using whenever used in declare expression rule)
  • Try to use it, only when it requires.
  • Explore the OOTB rules like – VerifyProperty & VerifyPropertyWithListing flow actions and activity rules.

 

There are 4 remaining methods which are inter related.

  • Property-set-Corr
  • Property-set-HTML
  • Property-Set-XML
  • Property-Set-Stream

These methods are help in saving the HTML or XML contents in a single value property. Then the property value can be used to communicate with external system.

6. Property-set-Corr

  • This method helps in saving the contents of a Correspondence Stream into a single value property.

7. Property-Set-HTML

  • This method helps in saving the contents of an HTML Stream into a single value clipboard property.

8. Property-Set-XML

  • This method helps in saving the contents of XML Stream rule into a single value property

9. Property-Set-Stream

  • This method helps in saving either the HTML Stream or XML Stream into a single value clipboard property.

When do we use these methods?

  • When we need to send the request/response to an external system.

The request can be of XML content ( In case of Web services like SOAP, REST) or it can be HTML contents ( Email correspondence)

Note: XML or HTML can include directives to reference the properties.

What are the method parameters?

Property-Set-Corr

a) PropertyName – You can specify the target property name to hold the correspondence stream content.

b) CorrStream – Specify the Correspondence rule name – second key part

c) CorrType – Specify the correspondence type name.

Property-set-HTML

a) PropertyName – Target property name

b) HTMLStream – Source HTML Stream name

Property-Set-XML

This is similar to Property-Set-Corr method.

a) PropertyName – Specify the single value target property name

b) XMLStream – Specify the XML Stream rule (Source)

c) XMLType – key part of the XML Stream rule

Property-Set-Stream

a) PropertyName – Specify the target property name to hold the stream contents.

b) StreamClass – Specify the rule type of the Stream

It can be any one of the following

  • Rule-Obj-Corr
  • Rule-Obj-HTML
  • Rule-Obj-XML
  • Rule-Corr-Fragment
  • Rule-HTML-Fragment

c) StreamName – Enter the main key part of the Stream name ( HTML or XML)

d) StreamType – This is applicable only for Correspondence and XML.

Property-Set-Stream helps in setting all types of stream value content into a single value property.

Let’s test it.

Step 1: Create a new test activity.

Step 2: Add a new step with property-Set-Stream method,

Step 3: Add a new step Show-Page for testing.

Step 4: Run the activity.

You can test other methods too 🙂

These 4 methods are just simple. You set the HTML contents or XML contents to a single value clipboard properties.

We are at the end of analyzing activity methods on clipboard properties 🙂

Catch you guys in next post!!!

 

 

  1. Dean Ambrose Dean Ambrose

    Very nice post man…It would be nice if you introduce us to Pega database quering with overview on database and query methods like Obj-Browse,Obj-Open..etc with scenario specific examples..You’re posts are awe-inspiring..just keep up the great work..

    • Premkumar G Premkumar G

      Thank you so much, Dean. Yeah, I’ll explain about them.
      Happy to read your comments. Thank you so much. 🙂

  2. Dharma Dharma

    Good Explanation PREM…

    Thanks for Detailed Info.. it will be helpful if your are explaining about the Looping and Jump Concepts .. in Property-set we used to call some expressions and page inside …:)

    Keep post .. Really Likes ur posts lot.

    Thanks.

    • Premkumar G Premkumar G

      Thank you so much for your appreciation, Dharma. You are welcome.
      I’ll post about those topics soon. Stay tuned. 🙂
      Happy to hear that you enjoy my posts. 🙂

  3. Naresh Naresh

    Hi Prem…,

    Thank you so much for your explanation on Pega Topics.

    Could you please explain what are the main differences between Property-Set and Data Transform? For which scenarios we will prefer Data Transforms or Property-Set?

    • Premkumar G Premkumar G

      Hope I answered the same question from you in an FB group 😛

  4. Ramya Ramya

    Nice Explanation. Can you please post about Report Definition.

    • Premkumar G Premkumar G

      Thank you, Ramya. 🙂
      I’ll post about it soon. Stay tuned. 🙂

Leave a Reply

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

error: Content is protected !!