EnsurePrimitiveValueNode
Ensures that an action parameter node exists in the configuration XML for the specified primitive value.
Syntax
function EnsurePrimitiveValueNode(configXml, sNodeName, sType, sDefaultValue)
Parameters
- configXml
- Type: Document
Required. The configuration XML document.
- sNodeName
- Type: String
Required. The name of the parameter node.
- sType
- Type: String
Optional. The data type of the primitive value node.
- sDefaultValue
- Type: String
Optional. The value of the primitive value node.
Remarks
This function ensures that a child node, representing a primitive value, exists in the Parameters node of the NWActionConfig node for the configuration of a workflow action.
You can use this function in the TPARetrieveConfig and TPAWriteConfig functions, included in the ControlBody control of a custom workflow action, to ensure that a node exists before attempting to read or write the value of an action parameter in the configuration XML.
Invoking this function performs the following actions:
-
Attempts to retrieve a Parameter node, with a Name attribute that matches the name specified in sNodeName, from the Parameters node in the NWActionConfig node of the configuration XML.
-
If the Parameter node does not exist, the function performs the following actions:
-
The function creates a new Parameter node and sets the Name attribute to the name specified in sNodeName.
-
The function creates a new PrimitiveValue node, as a child node in the new Parameter node.
-
The function creates two new attributes, named Value and ValueType, for the new PrimitiveValue node, and then sets the values of those attributes to the values specified in sDefaultValue and sType, respectively.
-
-
If the Parameter node does exist, the function sets the value of the Value attribute for that node to the value specified in sDefaultValue.
Example
The following example demonstrates how to use this function to ensure the existence of a Boolean parameter prior to writing its value in the TPAWriteConfig function of a custom workflow action:
// Use EnsurePrimitiveValueNode to ensure that the parameter node exists. EnsurePrimitiveValueNode(configXml, "BooleanParameter", "Boolean"); // Write true or false as the value of the parameter node, depending on the value of a checkbox on the // configuration page. configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='BooleanParameter']/PrimitiveValue/@Value").text = (document.getElementById("chkBooleanParameter").checked ? "true" : "false");
See Also
Concepts
Operations
Working with the ContentHead control