You need to sign in to do that
Don't have an account?
MANAGER_NOT_DEFINED Error when submitting records for approval
I'm using a trigger to submit custom object records for approval as soon as they are created. Here is the code that submits the record(s):
trigger modSubmitter on Modification__c (after Insert) { Approval.ProcessSubmitRequest[] reqs = new Approval.ProcessSubmitRequest[]{}; for(Modification__c m : Trigger.New){ if(m.Status__c!='Approved'){ Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest(); req1.setObjectId(m.id); reqs.add(req1); } } if(reqs.size()>0) Approval.ProcessResult[] result = Approval.process(reqs); }
I then try inserting a record and it fails because an exception is thrown, error is "MANAGER_NOT_DEFINED". All users involved in the process have managers defined in their user records... plus the approval process doesn't look at the manager field on any users anyhow... it just uses 'related user' lookup fields for all steps.
The API docs just say that this error means there is no manager for the approval process, which doesn't help much. I scoured the Apex guides to see if there were more Approval methods available for somehow defining a "manager" for the request, but there is nothing.
Any ideas?
I figured this one out. By "manager" this error message really means "next approver". It took a lot of debugging and trial and error, but I figured out that the issue was actually my before insert code that was supposed to be populating the lookup fields that would define the approvers. Hence the process didn't have an approver to assign it to.
Approvers are not always the "manager" of the person submitting the approval... I think this error code should be changed.
Can I ask what was the solution for this problem? I get the same error
can u please share the solution of this issue?
It is always a bummer when people find solutions to something...tell you they found it in a forum, but don't give you the solution.
I ran into the same problem. I found two ways to correct it:
1. I went to my own user settings and added an approver in the approver field used by my approval process. This worked fine. It appears the system runs the automated test as you.
2. You can run the test by any user in your org. This link gives you the information for how to set this up. If you have a test user that you used to create your approval processes, you would want to run your trigger as that user. :http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_testing_tools_runas.htm
What this really means is as follows:
On a given approval step, you might have chosen the "related user" who would approve this record. This would be a lookup field on the object that points to a user. Let's say the field is called "X". When the record enters this approval step and X is empty, you will get MANAGER_NOT_DEFINED error.
The solution is to make sure "X" is always set when you enter this step.
And the start of my Process should be : when a record is created or edited. since the approval process comes after a series of editing.
for your immediate help please
The solution was to fill out all the the possible Assigned Approver fields for the record you are submitting.
We had this issue when trying to submit for approval in a test class.
The cause of our error was that the user assigned to the record has become inActive, so you might want to check that out!
Hope it helps!