Skip to main content



No record found.

Microsoft Dynamics AX forum
Suggested answer

curUserID() in Workflow

Posted on by 1,270


  I'm trying to get the approving user out of a workflow.  In the completed method of the Workflow event handler the curUserId() method is called in an attempt to get the user who approved the process.  This value is then stored in a table for future reference.  The issue is the user returned is not the user who set off the approval.  I suspect the user context of the workflow event is separate from the user context of the front end.   When I run this code as a job the user is returned correctly.

  will curUserId() work within a workflow event handler?



  • David Rose Profile Picture
    David Rose 1,270 on at
    RE: curUserID() in Workflow

    Thanks all,

    I actually found that when running in the context of the workflow, curuserid() never returned the correct value of the user who kicked off the workflow.  I had to workaround by putting another form in btween the submit button and the workflow running.  Running as the form the curuserid was picked up correctly then I went back to the workflow.  Doesn't nessesarily have to be a form


  • David Rose Profile Picture
    David Rose 1,270 on at
    RE: curUserID() in Workflow

    Thanks Zeeshan,

     I've tried implementing this join for a quality order workflow but I'm having trouble getting it to return the correct values.  I haven't fully debugged it yet though.  With more effort perhaps I could make it work.

     I looked into the curUserID within the workflow and found that it was returning the admin user.  So as I expected it is returning the context of the system account running the workflow event not the use who submitted the approval.

     I'm now leaning towards capturing the approver in code just prior to sending the process off to the events handlers.



  • Suggested answer
    RE: curUserID() in Workflow

    Below code fetches the user id’s who approved the PO workflow.

    select firstonly workflowtrackingstatustable

    join workflowtrackingtable

    where workflowtrackingstatustable .ContextRecId == purchtable.recid

    && workflowtrackingtable.TrackingContext == workflowtrackingcontext::WorkItem

    && workflowtrackingtable.TrackingType == workflowtrackingtype::Approval

    && workflowtrackingtable.WorkflowTrackingStatusTable == workflowtrackingstatustable .recid;


    approvername = workflowtrackingtable.User;



Helpful resources

Quick Links

Can you answer this forum question?

You could make someone's day!

Community Newsletter - May 2024

Kudos to our community stars!

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,663 Super User

Martin Dráb Profile Picture

Martin Dráb 224,741 Super User

nmaenpaa Profile Picture

nmaenpaa 101,146

Featured topics

Product updates

Dynamics 365 release plans