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)

Getting ReferenceGroup value in x++

(0) ShareShare
ReportReport
Posted on by 282

Hi all,

I've got a display method which needs to check if there's a filled in value for the WorkerSalesResponsible for the sales order. It's sitting on the line of the form in a ReferenceGroup - but I don't know how to call for it in my method (ideally in a way that doesn't rely on it being on the form itself)

I was going to just use an SQL query, but I figured I'd ask before working out how SalesOrder relates to DirPerson and then to DirPersonName.

Thanks very much in advance

Luke

*This post is locked for comments

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

    Hi lukbel,

    the field WorkerSalesResponsible references the HCMWorker.RecId.

    If you just want to check if the field is filled you could do so by calling

    if (SalesTable.WorkerSalesResponsible != 0)

    (assuming you are inside the form somewhere)

    Regards

    Nils

  • Community Member Profile Picture
    on at

    The controls inside this ReferenceGroup just display the alternate primary key of HCMWorker. Correct me if i'm wrong.

  • lukbel Profile Picture
    282 on at

    Hi Nils,

    Sorry, I should have been more detailed - I'm needing to check the string that HCMWorker.RecId refers to (the actual name of the employee) contains a specific subString.

    I'm comparing it to a list of offline users which are stored as strings within my database. I've got ~95% of the code worked out, I just can't figure out how to check how HCMWorker links to an actual employee name.

    Regards

    Luke

  • Verified answer
    Community Member Profile Picture
    on at

    Hi lukbel,

    you need to select record in this way

    (I use a method, so it returns directly the name needed):

    public Name getEmployeeName(RecId _workerSalesResponsible )

    {

    HcmWorker           hcmWorker;

    DirPerson               dirPerson;

    DirPersonName     dirPersonName;

    select hcmWorker

    where hcmWorker.RecId == workerSalesResponsible

      join dirPerson

                    where dirPerson.RecId == hcmWorker.Person

               join dirPersonName

                    where dirPersonName.Person == dirPerson.RecId;

    return strFMT("%1 %2", dirPersonName.FirstName, dirPersonName.LastName);

    }

  • lukbel Profile Picture
    282 on at

    Ahhh - I was trying to link HcmWorker directly to DirPersonName

    I've adapted my original query

    Thanks

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