最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

Dynamics 365 财务和运营中的 RunAS 方法 / ‘RunAs’ method in Dynamics 365 FO

网络文摘 William 38浏览 0评论
Hi Folks,
Most of us have used RunAs earlier and it has the same use in D365Fo as well. Sometimes we came across where we need to run a specific business operation under a different user account than the currently logged-in user. To achieve this we can use RunAs to execute a specific operation. This enables the caller to run an X++ method in the security context of another user. This function is most often used with batch processing or workflow submission for another user.
The syntax is really simple as below,
container runAs(
        str userId,
        int classId,
        str staticMethodName
        [,
        container params,
        str company,
        str language,
        str partition
        ])
Parameter
Description
userId
The user to impersonate.
classId
The class to invoke in the impersonated session.
staticMethodName
The class method to invoke in the new user context.
params
The parameters to pass to the method; optional. 
company
The company that is selected for the impersonated session; optional.
language
The language that is selected for the impersonated session; optional.
partition
The partition key of the type that is returned by the getCurrentPartitionfunction; optional.
Now, let's see how to implement it and take an example of submitting a PR for a different user.
 
I need to submit a Purchase requisition on behalf of the different user through X++ code. To get this done I need a few details all in a single container type parameter
Hope it will help. Cheers!!! -Harry Follow us on Facebook to keep in rhythm with us. https:fb.com/theaxapta
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址