Skip to main content

Notifications

Announcements

No record found.

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

Multi select lookup doesn't return value on empty field!

Posted on by 186
I created a lookup using SysLookupMultiSelectCtrl and it's working fine but there is one case that has a problem:
When the Value field is empty and I choose some values and click select.. it's not reflected on the field and it's still empty.
 
but when the Value field already has a value and I modify it, the lookup selected values are reflected on the field text.(the 2nd picture)
 
 
 
Here's the code I use to handle this scenario:
 
[Form]
public class SetupForm extends FormRun
{
    SysLookupMultiSelectCtrl    msCtrl;
    str                         prevLookupValue = '';

    private str getLookupValue()
    {
        return con2Str(msCtrl.getSelectedFieldValues(),',');
    }
    
    public void init()
    {
        Query               q;
        FormStringControl   frmStringControl;
        FormRun             frmRun;

        super();

        q                = UtilityClass::getEmptyLookupQuery();
        frmStringControl = element.design().controlName(formControlStr(SetupForm,Grid_Value));
        frmRun           = frmStringControl.formRun();

        msCtrl = SysLookupMultiSelectCtrl::constructWithQuery(frmRun,frmStringControl,q);
    }

    private void getLookupQuey()
    {
        Query               q;
        FormStringControl   frmStringControl         = element.design().controlName(formControlStr(SetupForm,Grid_Value));
        FormRun             frmRun                   = frmStringControl.formRun();
        SetupTable          setupTable               = SetupTable_ds.cursor();

        If(setupTable.Field)
        {
            If(setupTable.Field == 'AccountNum')
            {
                if(setupTable.TableOption == TableOption::VendTable)
                    q = UtilityClass::getVendorLookupQuery();
                else
                    q = UtilityClass::getCustomerLookupQuery();
            }
            
            else If(setupTable.Field == 'CustAccount')
                q = UtilityClass::getCustomerLookupQuery();
            
            else If(setupTable.Field == 'CustGroup')
                q = UtilityClass::getCustGroupLookupQuery();

            else If(setupTable.Field == 'VendGroup')
                q = UtilityClass::getVendGroupLookupQuery();

            else
                q = UtilityClass::getEmptyLookupQuery();
        }
                        
        msCtrl.refreshQuery(q);
    }


    [DataSource]
    class SetupTable
    {
        public void selectionChanged()
        {
            super();
            element.getLookupQuey();
        }

        [DataField]
        class Field 
        {
            public void modified()
            {
                super();
                element.getLookupQuey();
            }
        }

        [DataField]
        class Value 
        {
            public void modified()
            {
                if(element.getLookupValue() != element.prevLookupValue)
                    DYNADDVTable.Value = element.getLookupValue();

                element.prevLookupValue = element.getLookupValue();
                super();
            }

        }
    }

}
 
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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans