Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

a control with the name already exists on the form when i build lookup with SysLookupMultiSelectCtrl

(0) ShareShare
ReportReport
Posted on by 25

Hello,

I want to make a contract parameter with MultiSelect, when i open dialogs for the first time, it's open without problem, but in my case I have to filter the multiselect based on another parameter contract, and so when I choose the value in the field on which I'm basing to filter the multi select and I open the lookup it gives this error 

"A control with the name 'Fld1_1_Ids' already exists on the form"

and error un this line

SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(), WMSAisleIdDialog.control(), query, false, selectedFields); 

and exctly in this control WMSAisleIdDialog.control()

thank you

  • Verified answer
    Martin Dráb Profile Picture
    232,982 Most Valuable Professional on at
    RE: a control with the name already exists on the form when i build lookup with SysLookupMultiSelectCtrl

    Moved from Microsoft Dynamics AX Forum to Dynamics 365 Finance Forum.

    As I said, you should call constructWithQuery() just once. You already seem to have a class-level variable for it (ctrlWMSAisleId).

    When you want to use a different query for ctrlWMSAisleId, you can set it by calling refreshQuery() method. For example:

    public void lookupAisle()
    {
    	Query query = new Query();
    	QueryBuildDataSource qbdsWMSAisle = query.addDataSource(tablenum(WMSAisle));
    
    	qbdsWMSAisle.addRange(fieldNum(WMSAisle, InventLocationId)).value(queryValue(strInventLocationId));
    	qbdsWMSAisle.fields().addField(fieldNum(WMSAisle, AisleId));
    	qbdsWMSAisle.fields().addField(fieldNum(WMSAisle, InventLocationId));
    
    	if (ctrlWMSAisleId)
    	{
    		ctrlWMSAisleId.refreshQuery(query);
    	}
    	else
    	{
    		container selectedFields = [tableNum(WMSAisle), fieldNum(WMSAisle, AisleId)];
    		ctrlWMSAisleId = SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(), WMSAisleIdDialog.control(), query, false, selectedFields);
    	}
    }

  • Tool Consulting Profile Picture
    25 on at
    RE: a control with the name already exists on the form when i build lookup with SysLookupMultiSelectCtrl

    public void lookupAisle()
        {
            Query					query		    = new Query();
            QueryBuildDataSource    qbdsWMSAisle     = query.addDataSource(tablenum(WMSAisle));
    
            if(strInventLocationId)
            {
                qbdsWMSAisle.addRange(fieldNum(WMSAisle, InventLocationId)).value(strInventLocationId);
                qbdsWMSAisle.fields().addField(fieldNum(WMSAisle, aisleId));
                qbdsWMSAisle.fields().addField(fieldNum(WMSAisle, InventLocationId));
                
            }
            else
            {
                qbdsWMSAisle.addRange(fieldNum(WMSAisle, InventLocationId)).value("");
                qbdsWMSAisle.fields().addField(fieldNum(WMSAisle, aisleId));
                qbdsWMSAisle.fields().addField(fieldNum(WMSAisle, InventLocationId));
            }
            
    
            container selectedFields = [tableNum(WMSAisle), fieldNum(WMSAisle, aisleId)];
    
            ctrlWMSAisleId = SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(), WMSAisleIdDialog.control(), query, false, selectedFields);
        }

  • Tool Consulting Profile Picture
    25 on at
    RE: a control with the name already exists on the form when i build lookup with SysLookupMultiSelectCtrl

    Yes, i'm in D365 F&O.

    and Yes yes I am based on the value of a parameter to filter the multi select lookup. so i change the query.

    please where can i use refreshQuery();

  • Martin Dráb Profile Picture
    232,982 Most Valuable Professional on at
    RE: a control with the name already exists on the form when i build lookup with SysLookupMultiSelectCtrl

    Which version of AX is it about?

    Constructing SysLookupMultiSelectCtrl again sounds wrong to me. If I understand this correctly, you want to change the query and you should use refreshQuery() method for this purpose. It's available in F&O, at least.

    By the way, let me change the category from Other to Development / Customization / SDK.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,241 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,982 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans