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

  • David Rose Profile Picture
    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

  • David Rose Profile Picture
    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.

    Thanks

    David

  • Suggested answer
    Syed Zeeshan Haider Jafry Profile Picture
    725 on at
    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;

    }

    Regards

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 48

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans