我正在尝试从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,它在我们确定的所有情况下都有效。当我们使用远程操作调用方法,并且运行的用户不是Opportunity owner或Quote creator (这些是审批工作流中的初始提交者)时,他们会收到以下错误:
NO_APPLICABLE_PROCESS, No applicable approval process found.Opportunity所有者和/或报价创建者可以使用远程操作提交,而不会出现错误。
有没有什么原因使得工作流在被remoteAction调用时不会被应用,而在不被调用时会被接受?有没有办法让这两个调用在相同的上下文中运行,这样它们就可以工作,而不是以相似的方式工作?
编辑:已更正以解决Gerard的评论
发布于 2012-08-23 01:57:41
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.https://stackoverflow.com/questions/12063400
复制相似问题