Related List Script not working

anfield
Tera Guru

I have a related list that I am trying to get working from the *clcl_devices table (from connected workspace app) - to the relationships table (cmdb_rel_ci). - to show parent computers.  As a test Ive hardcoded the sysid of the *clcl_devices device into the script and it works. However when I try to use current.sys_id to pull the *clcl_devices table sys id it doesnt work (the log shows no value)

 

Why would the script not be able to pull current.sys_id?

 

See the attached image for a screenshot of the query

 

*The community doesnt like that word so I had to put in an abbreviation.

 

Can anyone help?

 

 

Also my second question would be, in a related list how hard would it be to have the edit functionality in the list so that you can select and scroll from the list itself? The current list is just showing a new button

3 ACCEPTED SOLUTIONS

Dominik Simunek
Tera Guru

Use parent.sys_id to get the sys ID of the record on the form. Current in the script represents rather the query for records to be shown in the related list. (Answering shortly from my mobile, if needed, I could provide an example script later).

 

 

View solution in original post

Thanks. That works. parent.sys_id pulls the correct value

View solution in original post

@anfield 

No worries.

As per new community feature you can mark multiple responses as correct.

I believe I also answered your question and also the other part where you asked Edit button to be show. I shared explanation why it can't be shown

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

View solution in original post

10 REPLIES 10

@anfield 

No worries.

As per new community feature you can mark multiple responses as correct.

I believe I also answered your question and also the other part where you asked Edit button to be show. I shared explanation why it can't be shown

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

Ok. It should show as accepted now. Thanks

Sandeep Rajput
Tera Patron
Tera Patron

@anfield 

screenshot1.png

On line number 9, the parent sys_id doesn't look like a valid sys_id to me. Please verify.

 

Also, on line number 13, a variable query_string was declared but was not initialised.

 

please fixed it as follows.

var query_string = '';

That hardcoded sysid I changed just for this post, thats not the issue. Line 13 also not the issue. Now removed

Ankur Bawiskar
Tera Patron
Tera Patron

@anfield 

when you use defined relationship

current object - refers to Queries from table

parent object - refers to Applies to Target table

update line 6 as this to get the clinical device sysId

var parent_sysid = parent.sys_id;

for defined relationship it doesn't show Edit button and is known behavior.

Since defined relationship has custom query so system won't know what/which relationship you are editing.

That's the reason even if you try to Configure List Control and see the Omit Edit button is greyed out.

This KB mentions the same

The New or Edit button does not appear on a one-to-many related list

AnkurBawiskar_0-1740413338226.png

 

URL - https://instanceName.service-now.com/nav_to.do?uri=sys_security_acl.do?sys_id=c824e55473212300cf4794...

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