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 selected record sys id from releated list

Raghu Manchikan
Kilo Expert

Hello,

I have an ui action on task form and am passing sys id of the task to script include to get more details from server side. But when i click the same UI action from Requeste item related list   context menu this will not work because g_form.getUniqueValue() will give sys id of Req item instead of task sys id.

Please let me know how get sys id of an selected record from related list.

Regards,

Raghu

1 ACCEPTED SOLUTION

Raghu Manchikan
Kilo Expert

kalai - yes it is List action button.



I got the solution for this, below code gives sys id for both form level or if any record selected from related list.




if (typeof rowSysId == 'undefined')  


    sysIdnew = gel('sys_uniqueValue').value;  


else  


    sysIdnew = rowSysId;


View solution in original post

5 REPLIES 5

siva_dirisala
ServiceNow Employee
ServiceNow Employee

Hello Raghu, see the Context Menus -> Available Variables documentation.


BALAJI40
Mega Sage

Hi Raghu,



Yes obviously it will give reuest item sys_id only.


g_form.getUniqueValue() will give sys_id in client side what ever record of table you run.So it is on sc_req_item table record, that's why it give sys_id of that.


Kalaiarasan Pus
Giga Sage

Is it a list action button? Can you recreate this in a demo instance so that I can take a look ?


Raghu Manchikan
Kilo Expert

kalai - yes it is List action button.



I got the solution for this, below code gives sys id for both form level or if any record selected from related list.




if (typeof rowSysId == 'undefined')  


    sysIdnew = gel('sys_uniqueValue').value;  


else  


    sysIdnew = rowSysId;