Thursday, 28 March 2019

Cascading Drop Down in Pega

Cascading Drop Down in Pega


Hi all, In this Post we will see how to create Cascading Drop down using Report Definition in pega.

Below is the list of rule I created to implement this.

  1. Local Data Table
  2. Two Report Definition
  3. Flow
  4. Flow Action
  5. Section
  6. Two Property in Data Class and Two Property in Work Class.
I created a Class Named  Teky-PeopleNe-Data-ProductInfo . In this class I created two property named ProductName and ProductPrice .


I created ProductName as Key for this table and added some sample data.




Now our concept is on choosing the ProductName the corresponding ProductPrice we have to display in next drop down. So I created two Report Definition in Teky-PeopleNe-Data-ProductInfo class.


In the below report definition we get all ProductName which is not null.


In the below Report Definition we get the ProductPrice which corresponding to the ProductName



I created a flow in Work Class.

I created a section with two fields one for ProductName and another one for ProductPrice. Source for this property is a report definition.


ProductName property is mapped to source ReportDefinition named GetProductName


Add event for ProductName property as OnChange -> Post Value, if we are not using this event then changed value will not update to clipboard. So we are using Post value to update the changed value to clipboard. So we can pass Changed Property value to Next ReportDefinition named "GetProductPrice"


ProdPrice property is mapped to source ReportDefinition named GetProductPrice . Parameter for this report definition is ProductName.

Now lets check drop down value by running the flow.

Now price Corresponding to Samsung Lite is displaying in ProductPrice drop down.

Lets change another one value and check in Product Price.


Now you can see the value is changed in Product Price also.

I hope you understand this post😊

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.

Wednesday, 20 March 2019

How to Copy Messages in One Page to Another One Page in Pega

How to Copy Messages in One Page to Another One Page in Pega 

Hi all , During my work I faced one issue and the issue is when I am validating any property that is in Temporary Page , the message is correctly set in temporary page but that message is not displaying in the User Interface. I browsed the PDN , there I got one information and the information is Pega configured to display the messages that we are setting only in pyWorkPage not temporary clipboard page. In this post I will share how to copy the message from Temporary Clipboard page to pyWorkPage.

I created a Flow to get Employee Details in TGB-HRApps-Work Class and the Properties I created in TGB-HRApps-Data-Employee Class , Now If I want to use the properties that I created in Data class to Work Class I need to create one page in Work Class and I have to refer the data class properties using this page.


Reffered the data class property using Page "EmpPage" .


Pages and Class tab of section :


I added validation rule in flow action.

Now our Expectation is on run the flow if I leave the fields blank and then I click submit means it should through Validation Error. Let's check that. 

I created a new case and left all the fields blank , lets click submit button and test whether it shows error message or not. 


I clicked submit button and it not displayed any error message and completed the case.

  

If I checked the clipboard I can able to see page messages in "EmpPage" 



Validation message in clipboard but not displayed to user 

Pega will display message that is available only in pyWorkPage.

 So we have to transfer this message from EmpPage to pyWorkPage. So In Flowaction Post-Processing I added one activity.

 I added activity "PostEmployeeDetails" in Post-Processing 


I added a step to transfer message from Temporary Page to pyWorkPage.



In the step 1 , I added a when condition to check whether EmpPage contains messages using @hasMessages(EmpPage) method , if has message then get the message in EmpPage using @getMessagesAll(EmpPage) using step page as pyWorkPage. In the above activity I not provided the step page name. dynamically pyWorkPage will come as step page. 

Lets check again whether messages are copied to pyWorkPage or not by running the flow.

I am tracing this activity to check the background process.


In user Interface, now I can able to see the Validation Messages.

  

In tracer we can see the messages are available in pyWorkPage. 

Thats it. Hope you understand. 

Saturday, 9 March 2019

Important Java codes used in pega -Part 1

Important Java codes used in pega -Part 1


Hi Friends, Today we will learn below java functions in pega .


  1. How to get Parameter value in java code.
  2. How to put Parameter value in java code.
  3. How to get Clipboard Page in Java code.
  4. How to get property value from Clipboard Page in Java code

How to get Parameter value in java code?        

    Syntax: tools.getParamValue("ParameterName");

This function will return String value of the parameter name that we provide in the double quotes.

Let's Check this, I created one flow to get data like firstname and lastname. In the first assignment flow action I added one post processing activity In that activity I set one parameter. In the second step I added one java code to get the parameter value that I set in first step.

In the first step, I added one property set to set param value.

In the second step I added one  java step to get parameter value.
In the above java step I get the Parameter value of GetDataFinished and set that parameter value in another parameter named ValueinISGetDataFinished. Now lets run the flow and put trace open rule this activity to check function.


Now I processed the flow and my activity is get traced. Lets check

Here you can see the the value is get copied to new parameter. So this function is now working.

How to Put Parameter value in Java code? 

       Syntax :tools.putParamValue("ParameterNameToWhichToPutValue","Value");


How to Access Clipboard Page in Java Step?

    Syntax: ClipboardPage Page = tools.findPage("AnyClipboardPage");


what this function will do? . This function will return the clipboard page that we provide in the double quotes. With this page we can access all the property inside this page.

Let's use this function in our java step.
In the above code I am getting the pyWorkPage in WorkPage  and get the FirstName and Set the FirstName to "ParameterFirstName" parameter

Lets run the flow and check whether ParameterFirstName contains the name that we provide for FirstName in section.

I processed the flow and my activity is getting traced.

Let's check the parameter page.
In the above screenshot you can see ParameterFirstName is updated with name Rahul that I provided in section. So this function working in our java step.

How to get property value from clipboard page in Java?

       Syntax: ClipboardPage.getString("propertynamewithoutdot");


you can see this code I used in above example.