The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Send the 5 approval records at the same time

Venky Kshatriy2
Tera Contributor

Hi Team,

 

I have created on catalog item, that item contains the MRVS, inside the MRVS we have the approver's values.  i am sending the approvals by using the Flow designer, for MRVS to get one by one approval i used FOR EACH Logic ,the approval records created but I WANT TO CRATE THE ALL APPROVAL RECORDS AT A TIME.

 

Ex: MRVS contains the 5 records now we have 5 approvers i need to create 5 approvals records same time.

 

If any one knows could pls help on this 

Advance thanks Team

VenkyKshatriy2_0-1739186861410.png

 

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @Venky Kshatriy2 

 for (var i = 0; i < vk.length; i++) {
      var approver = vk[i].engagement_partner;
      gs.log('first approver'+approver);
      approvers.push({
          sysapproval: requestId,
          approver: approver,
          state: 'requested
 });
      gs.log('second approver'+approvers);
}
Remove following code:
var approvalGr = new GlideRecord('sysapproval_approver');
      approvalGr.initialize();
   

    for (var j = 0; j < approvers.length; j++) {
      gs.log('view thw rule')
      var vj = approvers[j];
      gs.log('mainvalues'+vj);
      var approval = approvalGr.createRecord();
      approval.sysapproval = vc;
      approval.approver = vj;
      approval.state = 'requested';
      approval.insert();
}
instead, add following:
if (approvers.length > 0) {
    var approvalGr = new GlideRecord('sysapproval_approver');
    approvers.forEach(function(approvalData) {
    approvalGr.initialize();
    approvalGr.sysapproval = approvalData.sysapproval;
    approvalGr.approver = approvalData.approver;
    approvalGr.state = approvalData.state;
    approvalGr.insert();
}
else gs.info('No approvers found, skipping approval record creation.');
});

View solution in original post

22 REPLIES 22

Mark Manders
Mega Patron

If you have 5 different approvers, they will be created one by one. It will be a minimal difference (time wise), but it will need to create a record for each of the variables, so that will always run one by one. Not sure if I understand the issue. 

 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Thanks @Mark Manders  Right now one by one only creating but is there any way to create all records at a same time

What do you mean? They are created in your 'for each', like you mentioned, right? That means that the flow is looping through them and creating them. You have them created within the for each loop. How more 'at the same time' do you need them to be created?


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

For each we can't is there any way is available to fetch all approvers from MRVS and send approvals records