We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

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

Tushar Walveka2
Tera Guru

try this

var tblName = g_list.getTableName(); 

var selSysIds = g_list.getChecked(); //get sys_ids of selected records from rel list

var sysIdList = selSysIds.split(',');  //Convert to Array

var numSel = sysIdList.length; //check length here