Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get values of current record from Related list UI Action?

Andrii
Kilo Guru

Hi,

I need to get some values of the current record from UI Action on Related List of current record - how do I do this?

1 ACCEPTED SOLUTION

RP.isRelatedList() && typeof parent != "undefined" && parent.state== 5


View solution in original post

5 REPLIES 5

sunilsafare
Mega Guru

Hi Andrii,



You can query the related list record based on the relationship. For instance to query the change task record on the change form, we can try this.



var gr_change = new GlideRecord(change_task);


gr_change.addQuery('change', current.sys_id); //Here change will be the reference field on the change task form.


gr_change.query();



while(gr_change.next()){


        //perform action


}


Thank you, Sunil, for trying to help me, but I need opposite - get values from Related List of the current record. I know I may use Script Include, but I'm looking for alternatives.


alexander_kubra
Giga Contributor

Hi Andrii,



Try RP.getParameterValue('sysparm_query'), it should return you the sys_id of the current record that's being referenced in the related list. I believe you should be able to make your way from there.


RP.isRelatedList() && typeof parent != "undefined" && parent.state== 5