web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

'RunAs' method in Dynamics 365 FO

(0) ShareShare
ReportReport
Posted on by 1,025

Hi expert,

I read this post about 'RunAs' method in Dynamics 365 FO

https://www.theaxapta.com/2019/05/runas-in-dynamics-365-fo.html#:~:text=To achieve this we can,workflow submission for another user

Can't understand where should i write this part of code 

WorkflowUser  submitUser = DirPersonUserEx::worker2UserId(purchReqTable.Originator);
container     parm = [workFlowTypeStr(PurchReqReview), purchReqTable.RecId, wfComment, NoYes::No, submitUser];

RunAs(submitUser, classNum(myClass), staticMethodStr(myClass, SubmitToWorkflow), parm);
CodeAccessPermission::revertAssert();

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi,

    What is your exact requirement here?

    RunAs is used to execute the code with the security context of another user. Are you trying to execute the "SubmitToWorkflow" function as the Originator of the purchase requisition workflow?

  • source258147 Profile Picture
    1,025 on at

    Hi Gunjan Bhattacharyya,

    Yes I'm working in the same scenario

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi,

    From where do you want to execute this? Do you have a batch job where you want to submit these purchase requisitions?

  • source258147 Profile Picture
    1,025 on at

    Please forget about my previous answer.

    I have a custom payroll and it's work perfect there is a loan transaction in this payroll

    The scenario is

    HR creates the loan for employee "X" and submit the workflow

    I need the workflow work like that

    HR submit --> workflow go to "X" manager --> then go to the HR manager

    how can I do this in workflow

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi,

    Have you checked this link already? Looks similar to your requirement.

  • André Arnaud de Calavon Profile Picture
    301,053 Super User 2025 Season 2 on at

    Moved to the Dynamics 365 Finance forum.

  • source258147 Profile Picture
    1,025 on at

    Thanks work for me

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 559 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 464 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans