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, ...
Suggested Answer

Get Data from another Table?

(0) ShareShare
ReportReport
Posted on by 282

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,573 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,843 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
    282 on at

    Thank you Mohit.

  • Chomchanok Profile Picture
    282 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,573 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,843 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

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... 396 Super User 2026 Season 1

#2
Subra Profile Picture

Subra 323

#3
Martin Dráb Profile Picture

Martin Dráb 243 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans