Amit Gujarathi
Giga Sage
Giga Sage

Hi Folks, Welcome to another ServiceNow tutorial. IN this tutorial, we will look at how we can create a custom-related list in ServiceNow with very easy steps and a demo. The custom related list is created via relationship in ServiceNow so you can say that the topic here is ServiceNow Related list using relationship.

Let's first try to understand what is a related list in ServiceNow according to ServiceNow docs.

Related list: Defined related lists provide a list of any records you want at the bottom of the form.

For example, a simple defined related list that lists other rooms on the same floor may be placed on the Room form. This helps you quickly navigate between them. To create a defined related list, we'll need to use a little JavaScript. We'll work through this in more detail in Chapter 3, Server-Side Control. Create defined related lists You can add default-related lists to the form for all users to see when viewing records. Before you begin

Role required: admin About this task

For example, you may include a list of related incidents at the bottom of a problem record, or a list of members at the bottom of a group record. This functionality depends on reference fields or many-to-many table relationships. If two tables are related via the system dictionary, one can appear as a related list on the other.

Defined related lists allow relationships between arbitrary tables to be expressed as a related list. Any two tables that can have a logical relationship can appear as a parent/child pair via a related list. The following are some examples. On an incident record, show all incidents opened by the same caller. On a user record, show the last 20 transactions that the user has made. On an incident record, show all problems opened on the reported CI. These relationships are beyond the relationships normally defined in the system dictionary through reference fields and many-to-many relationships.

Every related list requires a relationship record. Before creating a relationship, verify that there is not an existing relationship record that already provides the needed information. Use the following steps to create a relationship record.

Procedure:

  • Click System Definition -- Relationships.
  • Click New.
  • Specify the relationship record fields.
  • Click Submit.

A related list on a form serves the purpose of providing additional information related to the form record and gives a quick overview of how the other records would be affected if something is modified in the current form record.

Also, it provides ease of creating new records or adding existing records, based on the permissions available to the user, from the child table for the parent one.

Here based on the related lists, you can easily tell that this user is an end-user since there is no role associated with the user, has a single group membership, and has an asset assigned.

Following are the types of related lists that are available:

  • Reference field association (for lack of better term)
  • Many to Many Definitions
  • Sys collections
  • Relationships

Please like follow subscribe to my channel Technomonk and press the bell icon to get the latest update on my new videos. Till then stay happy and safe.

Have a nice day.

Regards,

Amit Gujarathi

Comments
Laukik Udpikar
Tera Expert

Hello Amit,

Thanks for the explanation. I'm creating relationship between Alert and its related Technical Service Offerings.

I'm querying the first part as below

Applies to : Alert

Queries from table : cmdb_rel_ci

current.addQuery('child',parent.cmdb_ci);
current.query();

 

now I want to check the service_offering table for the queried records, where the name matches, and only show those records. Could you help me out here! let me know if this needs any more clarification.

Thanks

amol_joshi
Tera Contributor

I want to create a new related list that refers to an existing related list and displays records that relate to existing related list instead of a parent field. 

 

For example - On problem table , I have an existing related list which shows Incidents associated with that problem. I now want another related list that displays email addresses of callers from the Incident related list.

Basically a link between two related lists and NOT a link between a related list and a parent.

 

Can this be done?  Thanks

amol_joshi
Tera Contributor

Found the solution - 

 

var sysIDs = "";

var gr = new GlideRecord("incident");

gr.addQuery('problem_id.number', parent.getValue('number'));

gr.query();

while (gr.next()) {

sysIDs += ", " + gr.caller_id.sys_id;

}

current.addQuery("sys_id", "IN", sysIDs);

Ramkumar Paluri
Tera Contributor

Looking for solution to open a catalog item on the click of Action from CUSTOM Related list 

Need to able to create an RITM within RITM

Any suggestions are highly appreciated.

Version history
Last update:
‎10-11-2022 02:40 AM
Updated by:
Contributors