我正在尝试从remoteAction提交自定义对象以供审批。到目前为止,我们一直在使用Apex pageReference控制器方法,该方法已按预期工作。
审批请求的构建如下:
public static string submitQuote(id quoteId){
Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
req1.setComments('Submitting for Approval');
req1.setObjectId(quoteId);
req1.setNextApproverIds(new ID[]{UserInfo.getUserId()});
Approval.ProcessResult pr = Approval.process(req1);
return 'Success';
}
如果我们从标准方法调用submitQuote,它适用于我们已经识别的所有情况。当我们使用远程操作调用方法并且正在运行的用户不是商机所有者或引用创建者(这些是批准工作流程中的初始提交者)时,他们会收到此错误:
NO_APPLICABLE_PROCESS, No applicable approval process found.
机会所有者和/或引用创建者可以使用远程操作提交但没有错误。
有没有理由说工作流程在被remoteAction调用时不适用,但在没有时会被接受?反正有没有让两个调用都在相同的上下文中运行,所以它们会工作而不能同样工作吗?
编辑:更正以解决杰拉德的评论
答案 0 :(得分:1)
Salesforce文档Using the with sharing or without sharing Keywords
Apex generally runs in system context; that is, the current user's permissions,
field-level security, and sharing rules aren’t taken into account during code execution.
Note
The only exceptions to this rule are Apex code that is executed with the executeAnonymous call.
executeAnonymous always executes using the full permissions of the current user.
For more information on executeAnonymous, see Anonymous Blocks.