- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 04:48 AM
Good Day Community
I am currently trying to create a related list on the Portfolio table.
This is my requirement:
- On the Project form there is currently a related list named "Actions".
- When a user creates an Action on the project form and the project is associated to a Portfolio then the actions on the project record should roll up to the Portfolio record.
This is what I have attempted thus far:
This is the related lists on the Portfolio record. I have created the Related List named Project Actions. Currently all actions are displaying. I only want actions associated to the specific Portfolio to display
Is there a way to achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 05:16 AM
I hope this will work for you as it worked for me
Please enhance as per your requirement
(function refineQuery(current, parent) {
// Add your code here, such as current.addQuery(field, value);
var projectArr = [];
var gr = new GlideRecord("pm_m2m_portfolio_project");
gr.addQuery("portfolio", parent.sys_id);
gr.query();
while (gr.next()) {
projectArr.push(gr.project.pm_project.toString());
}
current.addQuery('parent', 'IN', projectArr.toString());
})(current, parent);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 05:05 AM
seems you have created a defined/custom relationship between your Portfolio and the Actions table
you can use script in that and bring the actions for that Portfolio
1) Your current form is Portfolio so go to pm_m2m_portfolio_project table and get the Projects associated to this Portfolio
2) then once you get the projects query the project_action table with the above projects and push the sysId of Project Action
3) then form the query
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 05:09 AM
Hi @BiancaK ,
I believe you have already created a relationship in the Relationship Table. Now utilize the script section to establish a relationship between the Project Action and Portfolio Record.
Refer below example:
If my response helped, please mark it helpful and accept the solution so that it benefits future readers.
Regards,
Rohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 05:16 AM
I hope this will work for you as it worked for me
Please enhance as per your requirement
(function refineQuery(current, parent) {
// Add your code here, such as current.addQuery(field, value);
var projectArr = [];
var gr = new GlideRecord("pm_m2m_portfolio_project");
gr.addQuery("portfolio", parent.sys_id);
gr.query();
while (gr.next()) {
projectArr.push(gr.project.pm_project.toString());
}
current.addQuery('parent', 'IN', projectArr.toString());
})(current, parent);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 06:43 AM
Thanks @Ankur Bawiskar let me try this solution.