- 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:55 AM
You're still using a field called change_request on the change_request table. Did you not just say that field does not exist?
OK, let me know if I misunderstand something...
- At some point, you want to create a change request by triggering a business rule. What that trigger is yet, I don't know.
- When the change request is built, you want to related it to the problem request that generated it so it shows up on a related list of changes at the bottom of the form.
- Do you also want to save the newly created change request's sys_id in the problem's RFC field?
Such a business would look something like this. Keep in mind this is untested code.
Name: Create Change
When: Before
Advanced: true
Update: true
Insert: true
Condition: (you specify this)
Script:
(function executeRule(current, previous /*null when async*/) {
var chg = new GlideRecord('change_request');
chg.newRecord();
chg.u_problem = current.sys_id; // change u_problem to your field on the change request that points to the problem or task table
chg.short_description = 'Generated from problem ' + current.number;
current.rfc = chg.insert();
})(current, previous);
Depending on what field you use for u_problem, you'll need to add the proper related list to the problem form. For example, if you use a field that references problem, use Problem -> Change. If you use Task, you'll need Problem -> Task. The key here is that the field and what it references needs to coordinate with the related list you choose. It's as big of a difference as having a related list of incidents or users or CIs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 12:22 AM
Hi,
Thank you providing solution and i have tried as above but its not working.
Still i am not able to push the change request from reference field to the related list--change request tab.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 06:11 AM
Perhaps I am not understanding the requirement properly. Can you include screenshots to describe what you are trying to do? I'm sure it's not that complex.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 07:44 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 07:51 AM
Thank you. This should do the trick... keep in mind that it's untested...
Add it to an AFTER business rule like this:
Name: Update Change request parent
Table: Problem
Advanced; true
When: after
Insert: true
Update: true
Condition: current.rfc.changes()
Script:
(function executeRule(current, previous /*null when async*/) {
var change = new GlideRecord('change_request');
if (change.get(current.rfc)) {
change.parent = current.getValue('sys_id');
change.update();
}
})(current, previous);