Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Work Tasks

Pass Data to and from Widget

  • Last UpdatedNov 15, 2023
  • 2 minute read

The Hierarchy Selector uses the widget's Data property for incoming data and the Selected Object and Selected Value properties for outgoing data. The data must be in a JSON string (stringify) format to be recognized and passed to and from the widget.

To see the supported data structure and how Data, Selected Object, and Selected Value are used in the configuration file, see Hierarchy Selector Widget Properties Usage.

The following are examples of how the Selected Object and Selected Value properties are used for scripting to return an object (which is the selected child node) with all its properties and to return a specific object property, respectively. In both cases, the script is added to a property in a Work Tasks control.

In the following examples, the scripts are added to the Value property of a textbox control.

To retrieve the value returned for the selectedObj property

var temp = control.findByXmlNode("Widget1").widgetProperties.selectedObj;

var v ="";

if(temp != undefined && temp != "")

{

var reason = JSON.parse(temp);

if(reason != null)

{

for(var prop in reason)

{

if(reason.hasOwnProperty(prop))

{

//console.log(prop + ": "+reason[prop]);

v = v+ prop + ": "+reason[prop] + "\n";

}

}

}

}

return v;

To retrieve the value returned for the selectedValue property

var temp = control.findByXmlNode("Widget1").widgetProperties.selectedValue;

if(temp != undefined && temp != "")

{

return JSON.parse(temp);

}

else

{

return "";

}

The selected child node can either return an object or a specific object property. If it returns an object, the returned data is passed to the Selected Object property. If it is a specific object property, then the data is passed to the Selected Value property. You can define the specific object property under the defaultNodesMapping section of the configuration file.

If you want to access any of the properties of the returned object, the following is an example script that you can use, where it returns the value for the specified property or column field.

To retrieve the value of any property from the returned object

var temp = control.findByXmlNode("Widget1").widgetProperties.selectedObj;

if(temp != undefined && temp != "")

{

var reason = JSON.parse(temp);

if(reason != null)

{

return reason.reas_cd;

}

else

{

return "";

}

}

else

{

return "";

}

TitleResults for “How to create a CRG?”Also Available in