SetCustomPropertyValue()
- Last UpdatedFeb 07, 2024
- 2 minute read
Change the expression or reference of a custom property at run time.
Category
Graphic Client
Syntax
SetCustomPropertyValue(System.String name, System.String value, System.Boolean isConstant);
Parameters
|
Name |
The name of the custom property to be modified on the graphic. This is a string property and can be a reference or a constant. |
|
Value |
The new value to be set. Value is a string property and can be an expression, reference, or constant. If the value is given in quotes ("), then the value is considered a constant. If the value is given without quotes, then the value of the expression is considered a reference. |
|
isConstant |
IsConstant is a Boolean flag that indicates whether the new value will be evaluated as a constant or a reference.
|
Additional Information
The whole expression or reference of the custom property is replaced with the new value, regardless if it is overridden or not. No partial replacement is supported.
Only public custom properties on the graphic can be changed.
When the method executes, it overrides any modifications done by previous IOSetRemoteReference() calls from a native InTouch script.
Examples
Configuring the custom property as a reference:
Motor_001 is an object with the string attribute name "State" that stores the current state of the motor ("Running" or "Stopped"). You also have an Industrial graphic that has the string data type custom property "MotorState." The following script code will set the MotorState custom property to Motor_001.State in run-time:
GraphicA.SetCustomPropertyValue("MotorState","Motor_001.State",False);
As a result of the call, the function will set the string custom property GraphicA.MotorState to "Motor_001.State" as a reference. The string custom property GraphicA.MotorStatus will resolve that reference and update its value with the reference value ("Running" or "Stopped").
Configuring the custom property as a constant:
Motor_001 is an object with the Boolean attribute name "State" that reflects the current state of the motor (True or False). You also have an Industrial graphic that has the string data type custom property "MotorState." The following script code causes the MotorState custom property to hold the state of equipment—"Running" or "Stopped"—as text based on the value returned for Motor_001:
IF Motor_001.State THEN
GraphicA.SetCustomPropertyValue("MotorState","Running",True);
ELSE
GraphicA.SetCustomPropertyValue("MotorState","Stopped",True);
ENDIF;
As a result of the call, the function will set the string custom property GraphicA.MotorState to "Running" or "Stopped," depending on the value of Motor_001.State.