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

Hi,



Still its not pushing change to related list.


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.


Thank you so much now i am able to push change to related list.




Now i have one more query :


Problem state is 'resolved' and change required is 'yes' based on this condition only


Related list-->change request(Change request->Parent) should visible to user and Edit and New button should Omit.


Please help me to achieve this.



st.PNGcr.PNG



rtt.PNG



rrr.PNG



Please help me


If you want to make the visibility of the related list condition (show sometimes and hide others) use a client script using the method g_form.showRelatedList() and g_form.hideRelatedList().



Docs: Client Scripts


Docs: GlideForm


Client Script Best Practices - ServiceNow Wiki      



To hide the New and Edit button, use the Configure> List Control option and check those boxes.



Configure list controls


Thank you so much its working fine for me.




If we add a new button "Download" that if selected it will download the Document from ServiceNow



above is the one more requirement if possible please help to achieve,