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 253

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.

  • GirishS Profile Picture
    27,823 Moderator on at
    RE: Get Data from another Table?

    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.

  • Mohit Rampal Profile Picture
    12,556 Moderator on at
    RE: Get Data from another Table?

    You are welcome Thanakorn Kanjiropas

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

  • Chomchanok Profile Picture
    253 on at
    RE: Get Data from another Table?

    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.

  • Chomchanok Profile Picture
    253 on at
    RE: Get Data from another Table?

    Thank you Mohit.

  • GirishS Profile Picture
    27,823 Moderator on at
    RE: Get Data from another Table?

    Hi Thanakorn,

    Have you debugged the code?

    Seems the code looks good.

    Does the particular reason code have description?

    Thanks,

    Girish S.

  • Suggested answer
    Mohit Rampal Profile Picture
    12,556 Moderator on at
    RE: Get Data from another Table?

    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.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,884 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,760 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans