You need to sign in to do that
Don't have an account?
Salesforce running context when using @remoteAction vs. standard method Call
I am trying to submit a custom object for approval from a remoteAction. Up to this point, we have been using a Apex pageReference controller method, which has been working as expected.
The Approval request has been built as follows:
public static string submitQuote(id quoteId){ Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest(); req1.setComments('Submitting for Approval'); req1.setObjectId(q.id); req1.setNextApproverIds(new ID[]{UserInfo.getUserId()}); Approval.ProcessResult pr = Approval.process(req1); return 'Success'; }
If we call the submitQuote from the standard method it works in all cases we have identified. When we call the method using the remote action AND the running user is not the Opportunity owner or the Quote creator (these are the initial submitters on the approval workflow), they get this error:
NO_APPLICABLE_PROCESS, No applicable approval process found.
the Opportunity owner and or quote creator can submit using the remote action with out error.
Is there a reason that the workflow wouldn't apply when called by a remoteAction but would be accepted when not? Is there anyway to get both calls to run in the same context, so they will work and not work similarly?
Salesforce Documentation Using the with sharing or without sharing Keywords