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 :
Finance | Project Operations, Human Resources, ...
Unanswered

X++ code to fetch Purchase order assigned to the User

(0) ShareShare
ReportReport
Posted on by 5

X++  code to fetch Purchase order assigned to the User. To fetch the Purchase order assigned to any particular User(Approver).

I have the same question (0)
  • Community Member Profile Picture
    on at

    You may not get an answer here, this will mostly be Dynamics CRM users (Sales module).

    Consider posting on this forum:

    community.dynamics.com/.../microsoft-dynamics-ax-forum

  • Anusuyashankar Profile Picture
    5 on at

    Thank you Mike , I have posted in this forum.

  • WillWU Profile Picture
    22,363 on at

    Hi Anusuyashankar,

    Check the old thread:community.dynamics.com/.../which-ax-database-table-has-workflow-assign-to-user-info. and focus on Jonathan's answer,

     public display Responsible responsible()
    
    {
    
        WorkflowTrackingTable tracking;
    
        WorkflowTrackingStatusTable trackingStatus;
    
        WorkflowWorkItemTable workitem;
    
        Responsible ret = "";
    
        UserInfo user;
    
        select tracking order by tracking.createdDateTime desc join trackingStatus
    
            where tracking.WorkflowTrackingStatusTable == trackingStatus.RecId
    
            && tracking.TrackingType != WorkflowTrackingType::Completion
    
            && ((tracking.TrackingContext == WorkflowTrackingContext::Step) || (tracking.TrackingContext == WorkflowTrackingContext::Task))
    
            && trackingStatus.ContextTableId==this.TableId && trackingStatus.ContextRecId == this.RecId;
    
        select workitem where workitem.RefRecId == this.RecId && workitem.RefTableId == this.TableId &&
    
            ((workitem.Status == WorkflowWorkItemStatus::Pending) || (workitem.Status == WorkflowWorkItemStatus::Delegated));
    
        if ((tracking.RecId) && (workitem.UserId))
    
        {
    
            select user where user.id==workitem.UserId;
    
            ret = strFmt("%1 (%2)", tracking.Name, user.name);
    
        }
    
        else if (tracking.RecId)
    
        {
    
            ret = strFmt("%1", tracking.Name);
    
        }
    
        return ret;
    
    }

    Just need to replace "this" in the code with PurchTable.

  • Community Member Profile Picture
    on at

    Thank you Will Wu

    can please say how to fetch description of the below field by using X++ code.

    > Purchase Type

    > Approval Status(purchtable.DocumentState)

    >Purchase Order Status

  • Gunjan Bhattachayya Profile Picture
    35,429 on at

    Hi Anusuya,

    Could you please clarify what you are referring to as description of the mentioned fields?

  • André Arnaud de Calavon Profile Picture
    306,308 Super User 2026 Season 1 on at

    Hi Anusuyashankar,

    Can you tell about the business requirement here? What is the definition of a purchase order assigned to the user? Is it about a workflow assignment or purchaser field on the PO? Your question can be interpreted in various different ways.

  • saffarini Profile Picture
    45 on at

    pastedimage1672654622342v1.png

    the thing is I customized the purchase order and I need to bring the list of the users who created, verify, and approved the PO dynamically.

    as the users who are dynamically shown in the PO report will be coming from the Workflow of the PO, as it very based on the PO created(initiator) and the approved by person.

    I hope this is a clear question, as I will test and verify the above code if it works for me,  please feel free to advise and direct me to a best practice way for ditching the data in the photo colored at the bottom.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 407 Super User 2026 Season 1

#2
Subra Profile Picture

Subra 394

#3
Martin Dráb Profile Picture

Martin Dráb 275 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans