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

Get Data from another Table?

(0) ShareShare
ReportReport
Posted on by 276

Hi now I dev x++ for Data Provider

1.  Set up variable

ReturnReasonCode     ReturnReasonCode;
str                                 returnReasonCodeID;
str                                 returnReasonDesc;

2. I try to filter data in table ReturnReasonCode to show with criteria ReasonCodeId = custInvoiceJour.ReturnReasonCodeId

returnReasonCodeID = custInvoiceJour.ReturnReasonCodeId ;
returnReasonCode = ReturnReasonCode::find(ReturnReasonCode.ReasonCodeId);  // suspect this line error but what's wrong?

3. I show My string
if (returnReasonCode)
{
returnReasonDesc = returnReasonCode.Description; // Get the Description field from the ReturnReasonCode record
}
else
{
// Handle the case when the return reason code is not found
}

and of cause I didn't got error but nothing to show. what's wrong please help.

I have the same question (0)
  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi, If you want to find ReturnReasonCodeId of custInvoiceJour in returnReasonCode table then try below code where you mentioned '// suspect this line error but what's wrong?'

    returnReasonCode = ReturnReasonCode::find(returnReasonCodeID);

    You are finding returnReasonCodeID but not using it in ReturnReasonCode find method.

  • GirishS Profile Picture
    27,827 Moderator on at

    Hi Thanakorn,

    Have you debugged the code?

    Seems the code looks good.

    Does the particular reason code have description?

    Thanks,

    Girish S.

  • Chomchanok Profile Picture
    276 on at

    Thank you Mohit.

  • Chomchanok Profile Picture
    276 on at

    yes in my idea I want to get a description to show but it's sound like i'm in a rat race that test, debug.. bla bla but now i got answer already thank you too.

  • Mohit Rampal Profile Picture
    12,565 Moderator on at

    You are welcome Thanakorn Kanjiropas

    If Fixed, please mark answer Verified else let us know if still issue.

  • GirishS Profile Picture
    27,827 Moderator on at

    One more suggestion I have is, if you want only one field from ReturnReasonCode table - You can go for select statement by specifying the field to be selected from the database - This will increase your performance.

    ReturnReasonCode     ReturnReasonCode;
    str                  returnReasonCodeID;
    str                  returnReasonDesc;
    
    returnReasonCodeID = custInvoiceJour.ReturnReasonCodeId ;
    select firstonly Description from returnReasonCode
        where returnReasonCode.ReasonCodeId == returnReasonCodeId;
    if(returnReasonCode)
    {
        returnReasonDesc = returnReasonCode.Description;
    }
    

    Thanks,

    Girish S.

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

#1
Martin Dráb Profile Picture

Martin Dráb 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans