- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2016 06:58 AM
Hi,
In Problem,i have created the one reference field for change request based on if change required is YES and Problem state is resolved then the attached
change should display in related list->change request tab.
I have written below business rule but its not pushing to the change request in related field.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var rec = new GlideRecord('change_request');
rec.initialize();
rec.change_request = current.rfc;
rec.task = current.sys_id;
rec.insert();
})(current, previous);
Please help me to do this.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 08:35 AM
It worked for me. Please check your work closely to my notes.
I added this Change Request -> Parent list on my related lists.
And here's the complete business rule used to trigger the script:
If that doesn't work, check your permissions closely to make sure the tester has create and write permission on the change_request table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2016 07:06 AM
Your business rule is creating a new change request and expecting a change_request field there.
Shouldn't the field by u_problem? That's what you're saving (if the rest of the business rule config record is correct.)
Reference:
Business Rules - ServiceNow Wiki
Business Rules Best Practices - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2016 07:19 AM
Hi,
No its not creating new change request.
For reference field it not pushing the change request to the related list-->change request tab.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2016 07:22 AM
In order for the change request to show up on the related list (on the problem form) you need to relate the change request to the parent problem. That's the field you need to store current.sys_id in to. I highly doubt there is a change_request field on the change_request table (at least I KNOW there is no field like that out of the box.)
FWIW, your use case is good where one change request is related to one problem. You may want to consider the reverse case where multiple problems are related to a single change. This is where the problem.rfc field is handy. You would then have a related list of problems on the change form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2016 07:29 AM
Hi,
Yes you are correct there is no field like that.
(function executeRule(current, previous /*null when async*/) {
var rec = new GlideRecord('change_request'); // Its gliding to change record
rec.initialize();
rec.change_request = current.rfc; //this is the reference field what i have created for change in problem and storing in change request
rec.task = current.sys_id; // current sys_id i mean attached change request id
rec.insert(); //inserting to the related list--changerequest tab
})(current, previous);
Now please let me the solution.