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

Announcements

News and Announcements icon
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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans