Skip to main content

Notifications

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

how to hide Lookup column in multiselect lookup

(0) ShareShare
ReportReport
Posted on by 58

hello,

I created a multi select lookup using event handlers and I got my output.

I wrote code for one lookup field called custAccount but when I select the drop down CustAccount values are came but also custGroup and name column also came

but i need only custAccount lookup column but automatically custGroup and name colomns are came i need to hide them because it is my requirement.

please help me to sort out this.

below I attached my code for reference.

CODE:

public class AatMultiSelect_Form_Handler
{
   

    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormControlEventHandler(formControlStr(SalesTable, CustomerAccount), FormControlEventType::Modified)]
    public static void CustomerAccount_OnModified(FormControl sender, FormControlEventArgs e)
    {
        //FormRun formRun = sender.dataSourceObject().formRun();

        FormRun formRun = sender.formRun().dataSource().formRun();

        //FormRun     formRun = sender.datasource().formRun();

        SysLookupMultiSelectCtrl multiSelectCtl = formRun.parmMultiSelectCtl();

        SalesTable salesTable    =   formRun.dataSource(FormDataSourceStr(SalesTable, salesTable)).cursor() as SalesTable;
        salesTable.CustAccount   =   con2Str(multiSelectCtl.getSelectedFieldValues(), ';');
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>


    [FormControlEventHandler(formControlStr(SalesTable, CustomerAccount), FormControlEventType::Lookup)]
    public static void CustomerAccount_OnLookup(FormControl sender, FormControlEventArgs e)
    {
        FormStringControl CustomerAccount;
        SysLookupMultiSelectCtrl multiSelectCtrl;
        FormRun formRun = sender.formRun();
        AatMultiSelect_Form_Handler msCtrlClass;


        CustomerAccount = sender.formRun().design().controlName(formControlStr(salestable, CustomerAccount));
 
        multiSelectCtrl = SysLookupMultiSelectCtrl::construct(formRun,
                                CustomerAccount,
                                queryStr(CustTableSRS),
                                false,
            [tableNum(CustTable), fieldNum(CustTable,AccountNum), false]);

        msCtrlClass.parmMultiSelectCtl(multiSelectCtrl);

        FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;
 
        //cancel super() to prevent error.
        ce.CancelSuperCall();
    }

    public SysLookupMultiSelectCtrl parmMultiSelectCtl(SysLookupMultiSelectCtrl _multiSelectCtrl = multiSelectCtrl)
    {
        multiSelectCtrl = _multiSelectCtrl;

        return multiSelectCtrl;
    }

}

thanks,

Aathil Ameen  P

  • AXDynamics365 Profile Picture
    AXDynamics365 58 on at
    RE: how to hide Lookup column in multiselect lookup

    Thanks Girish S

    Thanks Mohit Rampal. It will helps me.

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: how to hide Lookup column in multiselect lookup

    Hi, Please check this article and instead of using CustTableSRS query, you can create query in code and add only CustAccount field in lookup.

    axhowto.wordpress.com/.../

  • Verified answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: how to hide Lookup column in multiselect lookup

    Hi Aathil Ameen,

    Account num, Cust Group and Name is shown because in the CustTableSRS query - Datasource >> CustTable >. Under field node you have Account num and Cust Group added >> Inside that DataSource you have DirPartyTable and it is having Name field. So, in the lookup you are seeing all the 3 fields.

    To avoid this, you need to duplicate the query and add Only CustTable as DataSource and add CustAccount as only field.

    You need to set the Dynamic Fields property to "No" on the DataSource level. Then only you can add your own fields.

    Later you can use that query instead of standard one.

    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,160 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans