function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
raj kiranraj kiran 

apex approval process not redirecting to right queue

Hi All,

I have approval process, for simplicity i am explaning with reference to sample approavl process, Example  i have kept  a condition like opportunity amount <10000 redirect to manager  or else  to comision team. at approval steps. If i submit the approval process by stanadard process, which is clicking on submit for approaval button  it is getting redirected  as required but with apex coding approval its does not properly do it.  This apex coding is used for auto submission for approval process when  some other field updates in the record happen.

Apex code used :
 Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
                                    req.setComments('Submitted for approval. Please approve.');
                                    req.setObjectId(getting it from custom apex page and vf page);
                                    req.setSubmitterId(getting it from custom apex page and vf page);
 approvalReqList.add(req);  
 if(approvalReqList.size() > 0)
                    {
List<Approval.ProcessResult> result = Approval.process(approvalReqList,false);
}


Now  my question is there any chance that apex approval might skip the redirection check or basically missing  any other validation before submitting. ?? or are there any thing which i need to add any other login to check for opp amount  before submitting.

Please share your taught .


Thanks
Raj
James LoghryJames Loghry
Theres not a whole lot to go off here.  Do you have any conditions that must be met for your approval process?  If so, is it possible that a workflow rule / field update, trigger, or process are getting in the way?
raj kiranraj kiran
James,
Thanks for your reply. Initial Entry criteria is met for my approval process. and step 1 entry criteria is not met. So as per logic it shoud redirect to step2. And yes there are quote a few trigger involved but they are not in picture to approval process conditions.

I have checked in backend values for the record which was wrongly moved to another queue,  as per values it shd be redireted to step2.


The flow is bit tricky here as we get the data from other external system. Let me give you an idea how it flows :

1)users  data from oracle system will flow(webservices) and it will update user records on nightly basis.
2) once the user is updated, trigger update will run and based on some changes in manager details and other job details updates of that user, these updates are pushed to another object called quota.
3) On quota object update triger will run and based on new values like newly  manager or new job details the apex code will run  for auto submisson .however it will also update some custom fileds on quota like auto submitted true etc when auto submission was done. These flags are not marked in back end as well.

there is a formula field involved in step 1 criteria , it will be updated on run time when user data is loaded from oracle these formula filed values will be updated . I have checked this field also and it was updated as well.

I am wondering if there any way , we can directly acess the approval process submit class or other which would give us the control like routing to various queues at coding level. so that this way i can again do the same approval flow redirection in coding level. Is this possible ?