- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@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);