Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

Modified method not working as expected in a certain scenario

Posted on by 1,081
Hi,

I have a custom table1 with the following fields
Id         name
id1        name1
id2        name2     

and another custom table2, the relation between table1 and tabl2 is Id
Number    Id       codeX      codeY      Field1
1               id1     codex1     codey1      fieldz
2               id2     codex1     codey1      fieldz
 
 
and in SalesLine, i added a field called codeX and Id  (relation between salesLine and table2 is codeX, and relation between SalesLine and table1 is Id)
and i overrided the lookup of this field codeX in salesLine, by creating a view that has table2 and table1, where it returns the following:
CodeX, name, Field1

so now when i click on the dropdown of this field I'm seeing this:
CodeX      name     Field1
codex1     name1   fieldz
codex1     name2   fieldz


my issue is if i choose in the lookup codex1 with name2, it actually takes codex1 with name1 instead.

 
[ExtensionOf(FormDataFieldStr(SalesTable, SalesLine, CodeX))]
final class SalesTableFormSalesLineDS_CodeX_Extension
{
    public void modified()
    {
        FormDataSource          formDataSource      = element.datasource();
        SalesLine               salesLine           = formDataSource.cursor();
        CodeX                   codeX               = salesLine.CodeX;

        next modified();

        Table1  table1;
        Table2  table2;

        select firstOnly CodeX, Id from table2
            where table2.CodeX == salesLine.CodeX
        join Id from table1
            where table1.Id == table2.Id


        salesLine.CodeX   = codeX;
        salesLine.Id      = table2.Id;

    }

}

 
Categories:

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans