Skip to main content

Notifications

Announcements

No record found.

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

how to display lookup in stringEdit form's control?

(0) ShareShare
ReportReport
Posted on by 920

hello , 

I want to add lookup in line details(accounts receivable> sales order >all sales order)

pastedimage1673428994100v1.png

this lookup displays data from cutomized table only for the current customer : 

this is the table : 

pastedimage1673429186310v2.png

I add new stringEdit control and i add this code in OnLookup event handler : 

[FormControlEventHandler(formControlStr(SalesTable, INTGroupingCode), FormControlEventType::Lookup)]
    public static void INTGroupingCode_OnLookup(FormControl sender, FormControlEventArgs e)
    {
        Query query = new Query();
        SalesTable salesTable = sender.formRun().dataSource("SalesTable").cursor();
        QueryBuildDataSource queryBuildDataSource;
        QueryBuildRange queryBuildRange;
        SysTableLookup sysTableLookup;
        sysTableLookup = SysTableLookup::newParameters(tableNum(INTGroupingCodeTable),sender);
        queryBuildDataSource = query.addDataSource(tableNum(INTGroupingCodeTable));
        queryBuildRange = queryBuildDataSource.addRange(fieldNum(INTGroupingCodeTable,CustomerAccount));
        queryBuildRange.value(queryValue(salesTable.custAccount));
        
        sysTableLookup.addLookupField(fieldNum(INTGroupingCodeTable,GroupingCode ),true);
        sysTableLookup.addLookupField(fieldNum(INTGroupingCodeTable, Description),true);
        
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
    }

but I can't display data.

  • BASMA Profile Picture
    BASMA 920 on at
    RE: how to display lookup in stringEdit form's control?

    thanks a lot :)

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: how to display lookup in stringEdit form's control?

    No you cannot use the same lookup.

    You need to create seperate method for new control added in SalesLine table.

    Thanks,

    Girish S.

  • BASMA Profile Picture
    BASMA 920 on at
    RE: how to display lookup in stringEdit form's control?

    I'm talking about the new fields that I added in SalesLine,

    I added it in 2 places (line details , grid) :

    pastedimage1673539560065v1.png

    I can use the same lookup ? 

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: how to display lookup in stringEdit form's control?

    Yes, you can add a same lookup code where you have added for your unbound string control. Just copy the lookup event handler for the control you created - Paste the event handler in your custom class - Now copy the code you had written for unbound control and paste it in the lookup method.

    Thanks,

    Girish S.

  • BASMA Profile Picture
    BASMA 920 on at
    RE: how to display lookup in stringEdit form's control?

    thanks for reply,

    yes I change this control, and i add new field in SalesLine

    then I add it in the form for save the value .

    also I add this field : 

    pastedimage1673538999799v1.png

    can I add also lookup in grid for the same field?

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: how to display lookup in stringEdit form's control?

    But keep in mind that if you make this control as unbound - This value cannot be saved any where on the table and its just for viewing purpose only. User can select the value from the lookup and the value will be displayed - But you cannot get the selected value if you need that in any of the process later.

    Thanks,

    Girish S.

  • BASMA Profile Picture
    BASMA 920 on at
    RE: how to display lookup in stringEdit form's control?

    thanks Girish,

    When I create a new line , I show the data on lokkup.

  • Verified answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: how to display lookup in stringEdit form's control?

    Okay, have you tried creating a new record on sales order lines?

    Just click on Add line button on sales order line tab and see whether the control is editable.

    Thanks,

    Girish S.

  • BASMA Profile Picture
    BASMA 920 on at
    RE: how to display lookup in stringEdit form's control?

    yes it's an unbound control ,

    the purpose is  :

    I have a customized table that contains codes for customer.

    I want to display on lookup , only codes for the current customer.

    there is no reltion between sales order lines and the lookup

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: how to display lookup in stringEdit form's control?

    What is the purpose of this string edit control you added? Seems it's a DataSource unbound control

    From the screenshot there is no Sales order line created - Try creating new sales line and check whether its editable.

    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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,966 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans