Marco Nappo_
Mega Guru

A demand can be associated with 1 or more stakeholders. Every stakeholder can be marked as assessment recipient and / or approver.

find_real_file.png

Once you click on Screen the demand move from Submitted to Screening, so all the assessment recipient can assess the demand answering the Assessment Metrics Related (OOB those metrics are related to Risks and Strategic Alignment)

Once the Screening process is completed the Demand move to Qualified. OOB all the Qualified demands need to be approved (Select for execution) by the portfolio manager on Step 2 (Select Demands and Projects) of Portfolio Workbench:

find_real_file.png 

As an alternative way, instead of waiting the Portfolio Manager to approve them you can ask 1 or more stakeholders (if approver related field is yes) to approve them. You can find the implementation Update Set as attachment on this article. Here is a description on how this is implemented

This approval process is NOT implemented OOB but can be easily implemented as follow:

  1. Enable Demand Approval Engine:
    1. As Admin go to System Properties -> Approval Engines
    2. Set Update Demand Approval Engine to: Approval Rules
  2. Add "Demand Approval Request" Business Rule
    1. Go to Business Rules
    2. Click New | Name: Demand Approval Request
    3. Table: dmn_demand | When to Run: (After) State changes to Qualified | Advanced
    4. Script:
      var grStakeHolder = new GlideRecord('dmn_stakeholder_register');
      grStakeHolder.addQuery('portfolio',current.portfolio);
      grStakeHolder.addQuery('approver','yes');
      grStakeHolder.query();
      while (grStakeHolder.next()) {
        //gs.log('Found an approver for demand ' + current.name);
        var grApproval = new GlideRecord('sysapproval_approver');
        grApproval.initialize();
        grApproval.approver = grStakeHolder.user;
        grApproval.state = 'requested';
        grApproval.sysapproval = current.sys_id;
        grApproval.insert();
      }
      ​
  3. Add "Set Demand to Approved" Business Rule
    1. AN: Business Rule | New | Name: Set Demand to Approved
    2. Table: dmn_demand | When to Run: (After) Approval changes to Approved
    3. Set Field Values: State to Approved
  4. Add Approvers related list on Demand
    1. On the Demand form, click on the form control (≡) icon and select Configure -> Related List
    2. Add the Approvers list to the Selected column.

After you have implemented the approver process all the demands are requested to be approved by all the stakeholders approvers as soon as you Demand is qualified.

A stakeholder approver can find all the demands that needs to be approved on My approvals

Comments
angelo nappi
ServiceNow Employee
ServiceNow Employee

Thanks Marko, this worked well.  Note that on creating the business rule, you also need to check the box for Update on the When to Run section.  When no options were checked I did not get any approvals created, worked great after checking Update.  FYI, I did not use the update set, just manually walked through all the steps in your post.

Yanal
Giga Guru

how can we make that any approvals can be enough to change the state to approved ?

 

harun_isakovic
Mega Guru

This works, but if the user is not part of the same Portfolio, it does not ask that user. Even though he is marked as an approver and added manually to the Stakeholder related list. This below (On After, Update) BR will work in that case.

(function executeRule(current, previous /*null when async*/ ) {

var sh = new GlideRecord('dmn_m2m_demand_stakeholder');
sh.addQuery('demand', current.sys_id);
sh.addQuery('approver', 'yes');
sh.query();

while (sh.next()) {

var userSysID = sh.stakeholder.user;
var approval = new GlideRecord('sysapproval_approver');
approval.initialize();
approval.approver = userSysID;
approval.state = 'requested';
approval.sysapproval = current.sys_id;
approval.insert();
}

})(current, previous);

 

 

Inactive_Us1738
Kilo Expert

Hi Marco,

Is there a way to achieve the same through workflow, please help us creating workflow, the whole idea is that to send notifications to stakeholder, we would like to send notification mail message with approval link to stakeholder, send notification mail to demand manager/project manager. 

From the approval engine we might not achieve sending notification mail to stakeholder & demand manager. Please help on this.

Thanks.

 

Brandon R1
Tera Contributor

@Marco Nappo  This is awesome!! Has this been tested with Rome and successfully works??

Also, in updating the Approval Engine for Demand in step 2, does the Demand Task also need to be updated to Approval Rules??

find_real_file.png

 

Brandon

 

Will West1
Tera Contributor

@Brandon R1 It should work in Rome and San Diego. You only need to enable Approval Engine on Demand.


@everyone considering deploying this solution:

Like harun_isakovic, I modified the provided code to create Approvals to use "Demand Stakeholder [dmn_m2m_demand_stakeholder]" instead of "Stakeholder Register [dmn_stakeholder_register. The Demand will automatically populate the dmn_m2m_demand_stakeholder from the dmn_stakeholder_register based on the Portfolio selected in the Demand but this allows a Demand Manager to modify the Stakeholders related to the Demand before triggering the Approvals.

 

I also updated the code to populate several fields on the "Approval [sysapproval_approver]" record to align to Approvals generated elsewhere in the platform.

 

(function executeRule(current, previous /*null when async*/ ) {
    var grStakeHolder = new GlideRecord('dmn_m2m_demand_stakeholder');
    grStakeHolder.addQuery('demand', current.sys_id);
    grStakeHolder.addQuery('approver', 'yes');
    grStakeHolder.query();
    while (grStakeHolder.next()) {
        var grApproval = new GlideRecord('sysapproval_approver');
        grApproval.initialize();
        grApproval.approver = grStakeHolder.stakeholder.user;
        grApproval.state = 'requested';
        grApproval.source_table = current.sys_class_name; // Not hard coded to support TeamSpaces
        grApproval.document_id = current.sys_id;
        grApproval.sysapproval = current.sys_id;
        grApproval.insert();
    }
})(current, previous);

 

PunithaDinesh
Tera Contributor

Thanks worked.

Version history
Last update:
‎11-26-2018 01:59 AM
Updated by: