Custom Related List Relation

Arjit Gourav
Tera Contributor

Hello,

 

We do have a requirement to include related incident of SCTASK in the related list of SCTASK form level. However, there is no direct related list selection available for this &  doesn't seem to be a field in incident storing SCTASK value either, that makes building relationship logic unfeasible.
Any suggestions for a workaround?

9 REPLIES 9

Ramz
Mega Sage

Hi @Arjit Gourav ,

You could achieve this using Relationships in Servicenow

- Navigate to System Definition->Relationships

-Create a new relationship as below:

(function refineQuery(current, parent) {
current.addQuery('request', parent.request.sys_id);
})(current, parent);
(Refer the screenshot)

-Note that request mentioned here is a field in incident form. Make sure request number is captured anywhere in your incident form or if it is not captured in any oob field , create a new field and capture it.

(Do a fix script for old incident)

-Add your created Related list to Task table by navigating to Configure->Related list and search for your related list and add it.Screenshot 2024-04-22 at 5.06.10 PM.pngScreenshot 2024-04-22 at 5.06.55 PM.png

 Please mark my answer helpful if it solved your query.Thanks!

Thanks for checking.

Just a small small correction. Instead of "parent.request.sys_id" , it has to be "parent.request.parent.sys_id" . 

Works now.

Hi @Arjit Gourav ,

Yep!It worked in my PDI.We have to tweak the query according to our instance .Glad it worked.

 Please mark my answer helpful/Correct answer if it solved your query.Thanks!

swathisarang98
Giga Sage
Giga Sage

Hi @Arjit Gourav ,

 

I have done something similar to this but in order to achieve this there should be a field in incident which will be capturing the sc task number that got created otherwise relationship can not be created,

 

Steps to create

1. Go to module relationships under system definition

2. In Applies to table give sc task

3. Queries from table as incident

 

and in script use the below,

 

current.addQuery('sctask_ref.number', parent.number);

 

here sctask_ref is a referencing to sc task table

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

Thanks.. Achieved with with the sys_id matching.