Question

How to get the value of property,where the property name is stored in another parameter

I need to get/set the value of/to a property in a page,where property name is stored in another parameter.

For instance ,let consider the name of the property as "XX".It is stored in the local parameter PropertyName.

How can i set any value to this property / get value from this property ?

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Correct Answer
September 2, 2016 - 7:59am

If you are doing this in an Activity and don't mind using Java Steps; you can use code like this:

  1. String PropertyName=tools.getParamValue("PropertyName");
  2. String PropertyValue=tools.getParamValue("PropertyValue");
  3. myStepPage.putString( PropertyName, PropertyValue );

I have a set of properties including 'title' and 'city' here; and using different parameters to my Activity the code above will set the appropriate property:

Here's the Parameter Tab for my Activity:

And the Steps - just a Page-New , the Java Steps (the code already pasted above), and a Show-Page:

For completeness here's the Pages & Classes tab, change this for your class structure of course:

 

And when I run this with the Parameter set to 'Title' :

The Show-Page confirms the '.Title' property is set:

  1. <pagedata>
  2. <pxObjClass>GCS-GCSApp-Work</pxObjClass>
  3. <Title>Hello</Title>
  4. <pzStatus>valid</pzStatus>
  5. </pagedata>

If I run it again with 'PropertyName' set to 'City', it changes to this:

  1. <pagedata>
  2. <pxObjClass>GCS-GCSApp-Work</pxObjClass>
  3. <City>Hello</City>
  4. <pzStatus>valid</pzStatus>
  5. </pagedata>

TIP: It is informative to use the 'Show Java' option on the 'Actions' Button on the Activity Screen in the Designer Studio - I used this to remind myself how to get at the API needed to fetch stuff from the parameters page for instance : just create a standard 'Property-Set' step which references 'Param.yourparam' , save the Activity and then 'View Java'.

Also: The Engine Java API is available from the Designer Studio from the Resources > Engine API menu. (on 721, other versions have a 'help' menu).

Useful Engine Classes to look at to start with:

PublicAPI (this is what 'tools' is an instance of, in automatic code)

ClipboardPage (this is what 'myStepPage' is an instance of , in automatic code).

ClipboardProperty

Hope this helps,

Cheers

John

 

 

 

Comments

Keep up to date on this post and subscribe to comments

Pega
September 2, 2016 - 4:50am

It would best to push the property value to the clipboard so that it would be easier to access.

Have you tried that already?

 

 

Pega
September 2, 2016 - 7:59am

If you are doing this in an Activity and don't mind using Java Steps; you can use code like this:

  1. String PropertyName=tools.getParamValue("PropertyName");
  2. String PropertyValue=tools.getParamValue("PropertyValue");
  3. myStepPage.putString( PropertyName, PropertyValue );

I have a set of properties including 'title' and 'city' here; and using different parameters to my Activity the code above will set the appropriate property:

Here's the Parameter Tab for my Activity:

And the Steps - just a Page-New , the Java Steps (the code already pasted above), and a Show-Page:

For completeness here's the Pages & Classes tab, change this for your class structure of course:

 

And when I run this with the Parameter set to 'Title' :

The Show-Page confirms the '.Title' property is set:

  1. <pagedata>
  2. <pxObjClass>GCS-GCSApp-Work</pxObjClass>
  3. <Title>Hello</Title>
  4. <pzStatus>valid</pzStatus>
  5. </pagedata>

If I run it again with 'PropertyName' set to 'City', it changes to this:

  1. <pagedata>
  2. <pxObjClass>GCS-GCSApp-Work</pxObjClass>
  3. <City>Hello</City>
  4. <pzStatus>valid</pzStatus>
  5. </pagedata>

TIP: It is informative to use the 'Show Java' option on the 'Actions' Button on the Activity Screen in the Designer Studio - I used this to remind myself how to get at the API needed to fetch stuff from the parameters page for instance : just create a standard 'Property-Set' step which references 'Param.yourparam' , save the Activity and then 'View Java'.

Also: The Engine Java API is available from the Designer Studio from the Resources > Engine API menu. (on 721, other versions have a 'help' menu).

Useful Engine Classes to look at to start with:

PublicAPI (this is what 'tools' is an instance of, in automatic code)

ClipboardPage (this is what 'myStepPage' is an instance of , in automatic code).

ClipboardProperty

Hope this helps,

Cheers

John