Configure : Parent/Child relationship for Problem table

Kingstan M
Kilo Sage

Hello SNC,

I have an requirement that - To add Parent/Child relationship for Problem table.

I.e., When i add list of problems in the related list problem tab then all those will be considered as child problem and thus when i open any child problem record then the parent problem number should be published in the related records >> parent problem.

Any advice?

find_real_file.png

1 ACCEPTED SOLUTION

Mahendra RC
Mega Sage

Hello Kingstan,

To achieve this you can go to System Definition --> Relationships. Click on New button:

Create a new record as shown below:

find_real_file.png

Put the below script in Query with field on your record :

(function refineQuery(current, parent) {
	var parentProblemID = parent.getValue("parent");
	current.addQuery("sys_id", parentProblemID);
})(current, parent);

Go to the problem table and open any child problem record. Right click on form header go to Configure --> Related Lists

Search Parent Problem under Available section and move it to selected section and click on Save

find_real_file.png 

You will now see the Parent Problem related list which will show the Parent Problem.

Please mark my respsone as helpful/correct, if it answer your question.

Thanks

View solution in original post

11 REPLIES 11

MrMuhammad
Giga Sage

Hi @Kingstan M 

I assume you are using Parent field to build parent/child relationship b/w problems. If so, you can go to Configure > Related list and add Problem -> Parent. This will give you child problems for the current record in the related list. 

For displaying parent problems in the list you need to build defined relationship [custom relatedlist]. You can see the documentation here at Create defined related lists | Servicenow Docs

At the bottom of the page you have couple of example codes which can be handy.

Let me know if you have any questions.

Please mark this helpful/correct, if applicable.

Regards,

Muhammad

Regards,
Muhammad

Hi Muhammad, Thanks.

But if you see my screenshot. I have already established parent relationship via related list (See screen-grab at related list). I created on field at the form as Parent problem (See screen-grab at problem form).

Now, My objective is to create parent-child relationship.

i.e., on the related list when i choose a problem it will be child of that parent. Thereby in the form of the child at parent problem field that parent problem should reflect.

Any advice?

@Kingstan M - Please create a Relationship by navigating to System Definition > Relationps.

Below is the configuration:

Name: Name of your choice. This will appear as label on the related list.
Parent: Problem
Child: Problem

Script:

find_real_file.png

(function refineQuery(current, parent) {

	// Add your code here, such as current.addQuery(field, value);
	current.addQuery('sys_id', parent.parent);

})(current, parent);

Open Problem form, Configure Related list and add "Custom Problem" [name of custom relations we built above].

Now the parent problems will appear on the child problem.

Please mark this helpful/correct, if applicable.

Regards,
Muhammad

Pavankumar_1
Mega Patron

Hi,

please refer below link.

https://community.servicenow.com/community?id=community_question&sys_id=7581136ddbdcdbc01dcaf3231f96191d

 

Thanks,

Pavankumar

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar