Create a related list on the Portfolio table

BiancaK
Tera Expert

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

BiancaK_0-1740574008696.png

Is there a way to achieve this?

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@BiancaK 

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);

AnkurBawiskar_0-1740575617854.png

 

project portfolio related list.gif

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Thank you so much @Ankur Bawiskar this worked!