+ Start a Discussion
Victor19Victor19 

Apex Approval Process

Hi,

 

I am trying to setup a dynamic Approval Process. I would like to reference the different queues that I have created in my org for my custom approval process. Can someone please help me out on how to get this started.

 

Any suggestions or sample code would greatly help me out.

 

Thanks!

 

 

Sonam_SFDCSonam_SFDC

Hey Victor,

 

The object you will have to work with in order to access Queues is the QSObject :

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_queuesobject.htm

 

Check the following thread to get an idea on how to access the Queue members:

http://boards.developerforce.com/t5/Apex-Code-Development/API-access-to-queue/td-p/167733

KodiKodi

Hi,  

This code apex trigger using approval process

 

trigger OpportunitySubmitForApproval on Opportunity (after insert) {
 
            for (Integer i = 0; i < Trigger.new.size(); i++) {
 
                if ( Trigger.new[i].TotalOpportunityQuantity== 2) {
                        // Trigger.new[i].Status__c='pending';
                    // create the new approval request to submit
                    Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
                    req.setComments('Submitted for approval. Please approve.');
                    req.setObjectId(Trigger.new[i].Id);
                    // submit the approval request for processing
                    Approval.ProcessResult result = Approval.process(req);
                    
                   // update opp;
                    // display if the reqeust was successful
                    System.debug('Submitted for approval successfully: '+result.isSuccess());
                    System.debug('Submitted for approval successfully: '+result);
 
                }
 
            }
 
        }

Victor19Victor19
Hi Sonam,

Thanks for the links :) Do you have any sample code for setting up an approval process using queues? If you do, could you please share it with me.. It will help me out a lot!

Thanks!
Vic
Victor19Victor19
Hi Kodi,

Thanks for the sample approval process trigger. Would you have happened to use any queues in setting up an apex approval process in the past? If so, can you please share your code!

Thanks!
Arunkumar.RArunkumar.R

Hi ,

 

Here is the code for Approval process and assigning  to queue members through apex trigger....

 

http://boards.developerforce.com/t5/Apex-Code-Development/Approval-process-through-Apex-trigger-issue/td-p/165373

 

Hope this may helpful to you....!