- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2015 04:28 AM
Hello everyone.
We have a business rule that creates a problem record automatically when a major incident record is resolved. Currently the business rule looks something like this:
var prob = new GlideRecord("problem");
prob.u_mi_reference = current.sys_id;
prob.short_description = current.short_description;
prob.description = current.description;
prob.cmdb_ci = current.cmdb_ci;
prob.u_category = current.category;
prob.priority = current.priority;
prob.u_source = 2;
However we are overhauling our Problem priorities so they will now be distinct from Incident priorities. Subsequently please can someone help tell me how I can set the new Problem priority based on the Incident one given that they are no longer matching? E.g. we will want the Problem record priority to be 'P1 - Critical' if the Incident has a priority of 'MI - P1' or 'MI - P2' or if the Incident is priority 'MI - P3' or 'MI - P4' then the Problem priority needs to be 'P2 - High'.
Many thanks in advance for any assistance.
Daniel
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2015 05:08 AM
You can define an array that will hold the mapping of incident to problem priority mapping.
Ex
var problemPriority = [];
problemPriority[1]=1;
problemPriority[2]=1;
problemPriority[3]=2;
problemPriority[4]=2;
prob.priority = problemPriority[current.priority];
Note : Change the values as per your need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2017 05:01 AM
Use while (glide.next()) rather than the if statement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2017 05:35 AM
By adding while instead of if it has gone into infinite loop. I can't understand why glide.u_property is giving value=undefined. I even tried glide.getValue('u_priority'); but that was returning null value to "pri".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2017 10:44 PM
If you're querying a row that has that field empty (no value set) you will get then undefined. You sure you have a value for all rows for that field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2015 05:07 AM
You can have a custom table to store the matrix for problem priority based on incident priority and in your business rule just query this table with incident's priority to get the relevant priority for problem. This would be easy to maintain as you just need to manipulate the entries in this table with out modifying the script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2015 05:08 AM
You can define an array that will hold the mapping of incident to problem priority mapping.
Ex
var problemPriority = [];
problemPriority[1]=1;
problemPriority[2]=1;
problemPriority[3]=2;
problemPriority[4]=2;
prob.priority = problemPriority[current.priority];
Note : Change the values as per your need.