Many to Many relation - Change & Problem

Puru2
Tera Contributor

Dear All,

I am working on Problem & Change request forms. A related list is present on Problem form which is used to populate multiple change requests (refer to below mentioned figure) :

find_real_file.png

However, when I am linking the change requests in problem form (as above) , the problem record is not getting linked to change request form : find_real_file.png    

Basically , the mapping is not functioning. Is there any code/script I am missing in order to facilitate this scenario ?

Please let me know your suggestions.

Best Regards,

Puru

4 REPLIES 4

lorisd_avanzo
ServiceNow Employee
ServiceNow Employee

Hi Pururava,



This is because you don't have the correct related list in your Change Request form. that related list named 'Problems' does not have the data you are looking for.



The 'Problems' related list is most likely the OOB related list that represents a 1-to-Many relationship between Changes and Problems.


To get data in that list you'll have to fill the change number in a 'Change request' field of a Problem, or simply use the Edit button.



From the related list of the Problem form instead, you can see that there is a filter from your screenshot (parent=PRBXXX). This represent another OOB 1-to-Many relationships, since any Task type (Problem/Incident/Change etc.) has got the parent reference field that can be used for parent relationships indeed.



OOB there is no Many-to-Many relationship between Problems and Change Requests, you may want to add one if needed (see also Create a many-to-many relationship ). After that, you can configure the related lists in the Change Request/Problem forms and add the related list of the Many to Many relationship you have just created.



I hope this helps.



Best Regards,


Loris D'Avanzo


Dear Loris,



Thanks for your suggestion !



I just have one query regarding your previous point. PFB the steps for the same :



1. In the *Problem* form, we can now edit multiple change requests via *Edit* option.  
2. The change requests linked to problem record (from step 1) should then contain *PRBxxxxx*   as a related record in *Problem* related list.



For implementation of above points, I have created a Business Rule which is as follows :find_real_file.png


Insert :   Checked
Update : Checked





But whenever I am updating the *Problem* field on change request form, then Related list of Problem form (containing change requests) is not getting updated with that parent change request number. It is still blank.



Do you have any suggestions on the same ?



Best Regards,Puru


lorisd_avanzo
ServiceNow Employee
ServiceNow Employee

Hi Puru,



As you said:


But whenever I am updating the *Problem* field on change request form, then Related list of Problem form (containing change requests) is not getting updated with that parent change request number. It is still blank.



The cause is probably in the code of your business rule:


current.setValue('parent',current.sys_id);



should be:


current.setValue('parent',current.u_related_problem);




Best Regards,


LD


ujjwaljain
Kilo Explorer

(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);






write the above code in your after insert update business rule. Bring Change Request->Problem related list on problem form