Demand Stakeholders

venuk
Kilo Contributor

i have many stakeholders configured for a portfolio but   when I create a demand I want the stakeholders auto selected based on the program selected not all the portfolio stakeholders (or) Related to a function that was entered in Portfolio management.

7 REPLIES 7

tekivijay
Giga Contributor

I have created this functionality with a after BR



You can customize the code for your requirement



function deleteStakeholders() {


  var gr = new GlideRecord('dmn_stakeholder_register');


  gr.addQuery('portfolio', previous.portfolio);


  gr.query();



  if (gr.hasNext()) {


  var m2mGR = new GlideRecord('dmn_m2m_demand_stakeholder');


  var stakeHolderList = "";


  while(gr.next()) {


  stakeHolderList += gr.getUniqueValue();


  stakeHolderList += ",";


  }


  m2mGR.addQuery('stakeholder', 'IN', stakeHolderList);


  m2mGR.addQuery('demand', current.sys_id);


  m2mGR.addQuery('auto', true);


  m2mGR.deleteMultiple();


  }



  gr = new GlideRecord('dmn_stakeholder_register');


  gr.addQuery('portfolio', current.portfolio);


  gr.query();



  if (gr.hasNext()) {


  m2mGR = new GlideRecord('dmn_m2m_demand_stakeholder');


  stakeHolderList = "";


  while(gr.next()) {


  stakeHolderList += gr.getUniqueValue();


  stakeHolderList += ",";


  }


  m2mGR.addQuery('stakeholder', 'IN', stakeHolderList);


  m2mGR.addQuery('demand', current.sys_id);


  m2mGR.deleteMultiple();


  }


}




function addStakeholders() {


  // Add new stakeholders for the current portfolio


  var gr = new GlideRecord('dmn_stakeholder_register');


  gr.addQuery('portfolio', current.portfolio);


  gr.query();


  while(gr.next()) {


  var m2mGR = new GlideRecord('dmn_m2m_demand_stakeholder');


  m2mGR.initialize();


  m2mGR.demand = current.sys_id;


  m2mGR.stakeholder = gr.getUniqueValue();


  m2mGR.auto = true;


  m2mGR.insert();


  }


}




if (!previous.portfolio.nil())


  deleteStakeholders();


addStakeholders();


Hi Venu,

How to restrict/remove autopopulate stakeholders list functionality in Demand.

Thankyou.

Josue Hernandez
Tera Contributor

Hello, Venuk

I do have the same question, I want to be able to autoselect the stakeholders in each demand, based on the portfolio and the program, not only the portfolio, I am wondering if you already identify a way to do that. if yes, can you share it with me?.  I think ServiceNow should add this option as part of the OOtB