- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2019 07:32 AM
Hello Team,
Need a help in creating business rule. I am new to servicenow.kindly help on this script.
We have related incident on problem task form and it is reference field to Incident table.once a user selects Incident,
the start and end times of that particular incident should populate in the respective fields on problem task.
Kindly help
Regards,
Swi
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2019 09:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2019 07:37 AM
Set up a before insert/update business rule on the problem table and trigger it with the incident reference field changes, the code will be simple, something like below, change field names as required:
current.start_time = current.incident.start_time;
current.end_time = current.incident.end_time;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2019 06:41 AM
Hi David,
Thankyou for your help.
I tried current.variable name on after update business rule and before update as well. It didnot work.
Actually i am writing script on problem task table.
my question is how to glide related incident (reference to incident table) field value on problem task and then how to get values of actual start and end dates of that particular incident selected by user on the problem task.
kindly help me with sample of entire script
Regards,
swi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2019 06:57 AM
Below is the script i tried for this scenario:
(function executeRule(current, previous /*null when async*/) {
var rel = new GlideRecord('problem_task');
rel.addQuery('problem_task', current.u_related_incident);
rel.query();
if('current.u_related_incident' != '')
{}
var gt = new GlideRecord('incident');
gt.addQuery('incident', current.u_related_incident);
gt.query();
if('u_related_incidentISNOTEMPTY');
{}
if(gt.next()){}
current.u_incident_start_time = gt.u_related_incident.gt.opened_at;
current.u_incident_end_time = gt.u_related_incident.resolved_at;
gt.update();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2019 07:07 AM