Predefined JavaScript Functions (Advanced Rules Only)
Demand Management provides several predefined JavaScript functions, which are listed in Table 5-5. JavaScript Functions for use with advanced rules. All of these JavaScript functions are dynamically applied in the request detail page when invoked by the respective rule, but most do not have any effect in other request edit interfaces (Quick Edit page, Mass Update page, Web service APIs to create or update requests). However, all of the "setFieldRequired()" rules are evaluated upon save in the other interfaces. Any field that is configured to become required as a result of rules is ultimately required when the request is saved, and if such a field does not have a value, then a message is displayed, indicating that the request(s) could not be saved.
JavaScript Function |
Description |
---|---|
setFieldRequired(<boolean flag>) |
Sets the field(s) as required or not required based on the flag parameter value. The Result Fields section must contain at least one field. |
setFieldEditable(<boolean flag>) |
Sets the field(s) as editable or read-only based on the flag parameter value. The Result Fields section must contain at least one field. |
setFieldVisible(<boolean flag>) |
Sets field(s) visibility based on the flag parameter value. The Result Fields section must contain at least one field. |
setFieldStyle(<CSS class name>) |
Sets the field(s) style to the CSS class specified. The Result Fields section must contain at least one field. Any custom styling you want to apply to request fields must first be defined in the Notes:
|
showMessage(<string text>, <boolean continueProcessing |
Show the message specified by the "text" parameter (enclosed in single or double quotes) and continue to process the request rule event based on the If |
addResource(<resourceFieldToken>) |
Adds the specified resource to the list of resources on the request. This rule only applies to request types that track resources. For more information about tracking resources, see Configure resource tracking. |