How do I write a business rule to take the value in a field and populate it to the close notes field on an incident record
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2018 01:59 PM
I have a requirement where I am needing to populate the incident close notes field with the value of a string field that was added to the approver form. The incident is tied to another form that is being approved. How do I write a business rule that will accomplish this?
Labels:
- Labels:
-
Scripting and Coding
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2018 01:14 AM
Hi Jim,
It sounds like you'll have to use 2 glide records to get to the parent incident at the top. Something like this should work in an after update business rule on the sysapproval_approver table, you'll obviously have to change the table and field names wherever necessary.
if(current.state = 'rejected'){
var rejection = current.getValue('u_reason_for_rejection');
var gr = new GlideRecord('u_it_request_questionnaire');
if(gr.get('sys_id', current.parent)){
var parentInc = gr.getValue('parent');
var gr2 = new GlideRecord('incident');
if(gr2.get('sys_id', parentInc)){
gr2.close_notes = rejection;
//add in whatever other changes you need to close the INC eg:
//gr2.close_code = 'it request rejected';
//gr2.state = 7;
gr2.update();
}
}
}