How could you get the risk assessment to calculate automatically?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2014 08:59 AM
How would you get the risk assessment calculate on a change request to populate as soon as you click submit on the assessment so you don't then need to click the UI action to calculate?
I tried piecing both the UI actions together (see below) but it's not performing the calculation. It saves the risk assessment but that's it.
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2014 09:28 AM
Depending on your version of ServiceNow, this functionality might already exist. You just have to adjust the system property, glide.ui.risk_calculate_rule, and set the value to business_rule
The business rule that does the automatic calculation is Calculate Risk
Business Rule: Calculate Risk
Table: Change Request [change_request]
When: before
Insert: true
Update: true
Condition: gs.hasRole('itil') && gs.getProperty('glide.ui.risk_calculate_rule') == "business_rule"
Script:
// This business rule checks Risk Conditions and returns risk and impact specified by ri.risk and ri.impact
// Labels for risk and impact are returned as ri.riskLabel and ri.impactLabel
// Other values that are returned include Name of the rule (ri.name) and order (ri.order)
// For validation with a form button, deactivate this business rule and activate the Calculate Risk UI Action
var scr = new SetChangeRisk();
scr.setRisk(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2014 10:59 AM
Hi Mike,
So in looking at this I'm sort of confused with the logic of the business rule. I have it use the BR instead of the UI action and that works fine. However, every single time the record is saved it reruns the calculation and pushes text to the top, even if the risk assessment didn't change.
That doesn't sound like a desired result. How can the condition be set up so it doesn't rerun the calculation unless the risk assessment is different?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2014 11:36 AM
Risk Conditions are dynamic, so you could set them up against any field. For example you could have risk conditions that runs against Planned start and end date fields changing, or Business Service changing, or group changing.
Since the risk condition is dynamic, it runs on every save using the Business Rule. To adjust it so it won't update the risk unless it changed, you would likely have to adjust the SetChangeRisk Script include. You would likely add if statements to check if the risk or impact changed.
...
if (current.risk != ri.risk) {
current.risk = ri.risk;
}
...
if (current.impact = ri.impact) {
current.impact = ri.impact;
}
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2014 04:53 AM
Hi mike,
I tried changing the property to business rule. but while creating a new change record an error message is displayed
invalid insert and Form is not getting saved.
can you please help me with this.
Regards,
Vijay Kumar