How to call a script include in the Relationship table?

thrsdy1512
Tera Expert

I have created a Script Include and want to call it in the below query, what is the best way to code this? I am creating a new relationship to display in a related list, similar to this: How to create Scripted Relationships or Defined Re... - ServiceNow Community

 

Thanks

thrsdy1512_0-1739956468075.png

 

 

11 REPLIES 11

I have a script include which pulls the process owner approval details from the related outage record and is also called as part of the approval flow process. Next steps for me are to define the relationship on the sys_relationship table and add a new related list on the change form that will display the Process Owners approval only. I have defined the relationship between the change table & the sysapproval table but the code i've tried so far seem to work. I know I need to call the script include but confused on how to get it to actually display the PO approval details. 

 

(function refineQuery(current, parent) {

    var returnValue = new ProcessOwnerApproval().functionName();

    current.addQuery("sys_idIN" + returnValue.toString());
})(current, parent);

Extract of the script include:
thrsdy1512_0-1739968649359.png

 

@thrsdy1512 

your understanding is correct.

the script include should return sysIds from sysapproval_approver table

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I have used this script but it has not worked unfortunately: 

(function refineQuery(current, parent) {

 

    var returnValue = new ProcessOwnerApproval().functionName();

 

    current.addQuery("sys_idIN" + returnValue.toString());
})(current, parent);

@thrsdy1512 

try this

1) you are not passing the CHG sysId to that function then how will it fetch the record

2) also ensure sysIds returned are for sysapproval_approver table records

(function refineQuery(current, parent) {

 

    var returnValue = new ProcessOwnerApproval().functionName(parent.sys_id);

 

    current.addEncodedQuery("sys_idIN" + returnValue.toString());
})(current, parent);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@thrsdy1512 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader