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 :
Microsoft Dynamics AX (Archived)

curUserID() in Workflow

(0) ShareShare
ReportReport
Posted on by 1,270

Hi,

  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?

Thanks

David

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Syed Zeeshan Haider Jafry Profile Picture
    725 on at

    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;

    }

    Regards

  • David Rose Profile Picture
    1,270 on at

    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.

    Thanks

    David

  • David Rose Profile Picture
    1,270 on at

    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

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans