Changing BR: Cascade Request Approval to Request Item

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2008 10:27 PM
I am trying to understand this business rule and if it can be changed to cascade a "Requested" approval state to Request Items. Thank you for the advice.
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sys_id);
gr.query();
while(gr.next()) {
if (!gr.cat_item.delivery_plan.nil())
startPlanApproval(gr);
else if (gr.cat_item.workflow && !gr.cat_item.workflow.nil())
startFlowApproval(gr);
else continue;
gr.update();
}
function startFlowApproval(gr) {
gr.approval = 'requested';
if (gr.stage == "waiting_for_approval" && current.approval == "approved")
gr.stage = 'Request Approved';
else if (current.approval == 'rejected')
gr.stage = 'Request Cancelled';
}
function startPlanApproval(gr) {
gr.approval = current.approval;
if (gr.stage == "waiting_for_approval" && current.approval == "approved")
gr.stage = getStageFromPlan(gr); // move them away from waiting for approval
else if (current.approval == 'rejected')
gr.stage = 'Request Cancelled';
}
function getStageFromPlan(reqitem) {
var nextStage = "nothing";
var planID = Packages.com.glideapp.servicecatalog.DeliveryPlan.resolvePlanID(reqitem);
// return the first delivery task
var gr = new GlideRecord("sc_cat_item_delivery_task");
gr.addQuery("delivery_plan", planID);
gr.orderBy("order");
gr.query();
if(gr.next())
nextStage = gr.name.getDisplayValue();
return nextStage;
}
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2010 05:22 AM
Hi, this is exactly what we want too but cannot seem to get this to work. The issue that we have is that the approval state cascades to the Requested Item whereby we want the approvals to occur at the Requested Item level rather than at the request Level. Also we cannot get the approver/sponsor to populate the Approvers related list within the Requested Item using the User Approval Activity in our workflow. Any help will be greatly appreciated! Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2013 09:23 AM
Hi Rish ,
I have a requirement to create an item which upon request should create approval and task for each CI requested in that item . So if user has requested 5 CI in that RITM then it should generate 5 approval and 5 tasks . I can see from this post that you managed to do that , can you please help me in understanding as this was done through the workflow or Business Rule ? Can you please let me know how you achived this ?