Important Java codes used in pega -Part 1
Hi Friends, Today we will learn below java functions in pega .
- How to get Parameter value in java code.
- How to put Parameter value in java code.
- How to get Clipboard Page in Java code.
- 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 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.
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.
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.
Please share part 2 of this post. This really helped me alot
ReplyDelete