Salesforce在使用@remoteAction与标准方法调用时运行上下文

Salesforce在使用@remoteAction与标准方法调用时运行上下文,salesforce,apex-code,Salesforce,Apex Code,我正在尝试从remoteAction提交自定义对象以供批准。到目前为止,我们一直在使用Apex pageReference控制器方法,该方法已按预期工作 批准请求已按如下方式生成: public static string submitQuote(id quoteId){ Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest(); req1.setComments('Submitting fo

我正在尝试从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 owner和/或quote creator可以使用远程操作提交,而不会出现错误

是否存在这样一个原因:工作流在被remoteAction调用时不适用,但在不适用时会被接受?有没有办法让两个调用都在同一个上下文中运行,这样它们就可以正常工作而不能正常工作

编辑:针对Gerard的评论进行了更正

Salesforce文档


在您的示例代码中,您似乎没有使用quoteId,而是使用q.id。谢谢您的关注。当我把它输入我的问题时,它实际上是o型的。q、 id是我用来调用这个方法的,所以q.id==quoteId不会在远程操作中投入太多的精力。我不得不在一个沉重的页面上不使用远程操作,因为它以某种方式干扰了另一个库。所以现在我意识到它不仅仅是一个js函数到一个静态控制器方法。
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.