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.

Table 5-5. JavaScript Functions for use with advanced rules

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 RequestRulesUserCss.css file, which is located in the <PPM_Home>/server/<PPM_Server_Name>/deploy/itg.war/web/knta/crt/css directory on the PPM Server.

Notes:

  • Not all styles on html elements are supported by Internet Explorer and Mozilla Firefox. Please consult the browser-specific implementation for information on which styles are supported.

  • border attribute for dropdown list is not supported by Microsoft Internet Explorer. This is a Microsoft Internet Explorer limitation.

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 continueProcessing parameter value.

If continueProcessing = false, then the event that triggered the rule is aborted. You can use this function to display a message that reminds the user that he must perform some action before he saves, and prevent the user from saving until he performs that action.

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.