Skip to main content

Notifications

Announcements

No record found.

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

Multiselect lookup value not saving in datasource/form

Posted on by 303

Hi.

I created a new field "BillType" in RetailParameters which will have multiselect lookup in RetailParameters form.I am able to select multiple values from the lookup but on clicking Save button or on refreshing the page the selection dissappears.

I want to save the values selected in the RetailParameters datasource so that I can fetch it later in my report based on the selection .

Please help me find what I am missing.

FYI. Form String control: BillType_InfoCode (auto declaration set Yes, Datasource,datafield not set)

1.In form extension class:
 public SysLookupMultiSelectCtrl msCtrlCust;
        public void init()
    {
        FormRun             formRun = this;
        //FormStringControl BillType_InfoCodeCtrl = formRun.design().controlName(formControlStr(RetailParameters, BillType_InfoCode));

        Query query = new Query();
        QueryBuildDataSource qbds;
        TableId     multiSelectTableNum = tableNum(RetailParameters);
        container   selectedFields      = [multiSelectTableNum, fieldName2id(multiSelectTableNum, fieldStr(RetailParameters,Billtype))];

        next init();
        
        qbds = query.addDataSource(tableNum(RetailInfocodeTable));
        qbds.fields().dynamic(true);
        qbds.fields().addField(fieldNum(RetailInfocodeTable,infocodeId));
        qbds.fields().addField(fieldNum(RetailInfocodeTable,description));
        //qbds.relations(true);
        //assigning control and query to the class
        msCtrlCust = SysLookupMultiSelectCtrl::constructWithQuery(formRun,BillType_InfoCode , query);
    }

    public void SetCustGroupLookpValues()
    {
        container ids;
        container recIds;
        int i;
        RetailParameters retailParameters;

        for(i=1;i<=conLen(str2con(retailParameters.BillType,';')); i  )
        {
            recIds  = RetailParameters::find(conPeek(str2con(retailParameters.BillType,';'),i)).RecId;
            ids  = conPeek(str2con(retailParameters.BillType,';'),i);
        }
        msCtrlCust.set([recIds,ids]);
        ids = conNull();
        recIds = conNull();
    }
   
   2.In form control class
   public boolean modified()
    {
        boolean ret;
        RetailParameters retailParameters;
        ret = next modified();

        ttsBegin;
        retailParameters.BillType = this.text();
        retailParameters.write();
        ttsCommit;

      
        return ret;
    }
    
    3.In form datasource class
    public int active()
    {
        int ret;

        ret = next active();

        element.SetCustGroupLookpValues();

        return ret;
    }

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