Not able to relate the change request to related list in Problem

kulkarnivivekn
Tera Contributor

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.

1 ACCEPTED SOLUTION

It worked for me. Please check your work closely to my notes.



I added this Change Request -> Parent list on my related lists.



find_real_file.png



And here's the complete business rule used to trigger the script:



find_real_file.png


find_real_file.png


find_real_file.png


find_real_file.png


If that doesn't work, check your permissions closely to make sure the tester has create and write permission on the change_request table.


View solution in original post

19 REPLIES 19

Chuck Tomasi
Tera Patron

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  


Hi,



No its not creating new change request.


For reference field it not pushing the change request to the related list-->change request tab.


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.


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.