• kohon
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hi All,

I have a custom Approve/Reject page and custom approval history.
How can I link both , like how to make it to go to the next approval step once it is approved/rejected.What am I doing wrong .pls let me know.
Here's the code.
    JS:
    approveall: function(component, event, helper) {          
            var allRecords = component.get("v.listOfAllAccounts");
            var recordId = component.get("v.recordId");
            var selectedRecords = [];           
            for (var i = 0; i < allRecords.length; i++) {
                if(allRecords[i].isChecked ){
            selectedRecords.push(allRecords[i].objAccount.Id);
   
            }
            }
            confirm("Do you want to proceed without any Comments?");            
            var action = component.get('c.approvereject');           
             action.setParams({
                "approvalId": selectedRecords,
               
         
            }); 
        
            //alert(JSON.stringify(selectedRecords));
            action.setCallback(this,function(response){ 
                var state = response.getState();
                 var records = response.getReturnValue();
        
                if(state == 'SUCCESS'){
                 component.set('v.recordId', records);                             
                   alert("Approved Successfully");
                   $A.get('e.force:refreshView').fire();
                }
                else{
                   alert("Failed to Approve all Records");
                }    
           
                    
            });
            $A.enqueueAction(action);
 
        },
        controller:
          @AuraEnabled
    public static void  approvereject(Id approvalId){ 
         String strComments;
        list<Opportunity> lstARDs = [select ID, status__c from Opportunity
        WHERE Approval__c=:approvalId ];
       for(Opportunity objARD : lstARDs){
        if(objARD.status__c==null)
        {
         objARD.status__c= 'Approved';        
           }
           else if(objARD.status__c=='Rejected'){
           objARD.status__c= 'Approved';
           }
       }
        update lstARDs;
        if(Approval.isLocked(approvalId)){
            Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
            req.setComments(strComments);
                req.setAction('Approve');            
            //Getting Work Item Id
            ProcessInstanceWorkitem pItem = [SELECT Id FROM ProcessInstanceWorkitem WHERE ProcessInstance.TargetObjectId =: approvalId];
            req.setWorkitemId(pItem.Id);
            // Submit the request for approval
            Approval.ProcessResult result = Approval.process(req);
           
        }
     
  • August 13, 2020
  • Like
  • 0
i'm trying to select all rows and approve them at once with the pagination., but only rows in first page are getting updated when i click on approve button eventhough all rows are selected.How do i make all rows updated at once
  • August 11, 2020
  • Like
  • 0
i'm trying to select all rows and approve them at once with the pagination., but only rows in first page are getting updated when i click on approve button eventhough all rows are selected.How do i make all rows updated at once
  • August 11, 2020
  • Like
  • 0