- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2017 12:50 PM
Hi,
I am working with the Project form in Servicenow. In my project form, I have a field named "Customer Name" which is referenced to the Company Table. The Company name in that field might have multiple projects. So, now, when a name is entered in that field, all the projects which are tied to that company should be listed as a related list on the project form.
Below is the snapshot of my Project form:
And, in the Companies list of my instance, I went and added an OOB related list "Projects" to the form. So, all the projects relating to that customer would be shown in that. The project in the above snapshot is shown in that Company's Projects Related List. Below is the snapshot:
So, I want the same related list to be shown on my Project form too. Unfortunately, there is no OOB related list Projects on the Project form. I know that I have to create a relationship to achieve this, but how can I create in this scenario as I have to pull information from related list on Company form? How can I get this?
Please let me know. Thanks in advance.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2017 01:10 PM
Hello Prudhvi,
Here are the steps.
1.Navigate to relationship module and create new
Name : Projects by same company
Applies to table " project(pm_project)
Queries from table : project(pm_project)
Script is
(function refineQuery(current, parent) {
// Add your code here, such as current.addQuery(field, value);
current.addQuery('u_customer_name', parent.u_customer_name);
})(current, parent);
Now step 2 go to the project table and add the relationship-->Right click on header->Configure->related list and search for the name Projects by same company and add on the form.
The relationship will be visible only when you save the record.
I hope this helps.
P.S: please make sure field column name is correct i.e u_customer_name

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2017 12:56 PM
Hi Prudhvi,
Yes, you can do this. Take a look at System Definition> Relationships. There's an existing OOB entry for Incidents by Same Caller that might help as an example.
http://wiki.servicenow.com/index.php?title=Creating_Defined_Related_Lists

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2017 01:10 PM
Hello Prudhvi,
Here are the steps.
1.Navigate to relationship module and create new
Name : Projects by same company
Applies to table " project(pm_project)
Queries from table : project(pm_project)
Script is
(function refineQuery(current, parent) {
// Add your code here, such as current.addQuery(field, value);
current.addQuery('u_customer_name', parent.u_customer_name);
})(current, parent);
Now step 2 go to the project table and add the relationship-->Right click on header->Configure->related list and search for the name Projects by same company and add on the form.
The relationship will be visible only when you save the record.
I hope this helps.
P.S: please make sure field column name is correct i.e u_customer_name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2017 10:12 PM
Hi Pradeep, This has worked for me. Thank you. In addition to it, I only want to show the active projects of that customer. (i.e The Projects in Closed Complete and Cancelled state should not be shown). Can we do that?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2017 10:35 PM
Here you go. Update the field column name and choice values accordingly.
(function refineQuery(current, parent) {
// Add your code here, such as current.addQuery(field, value);
current.addQuery('company', parent.company);
current.addQuery('state', '!=', 1); //Replace 1 with the exact choice value of Closed Complete
current.addQuery('state', '!=', 2); //Replace 1 with the exact choice value of Cancelled state
})(current, parent);