Skip to main content

Notifications

Announcements

No record found.

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
    225,155 Moderator 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
    225,155 Moderator 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

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Jahanvi Profile Picture

Jahanvi 34

#2
PJ JohnPaul Profile Picture

PJ JohnPaul 5

#3
SudhanshuMSID Profile Picture

SudhanshuMSID 1

Overall leaderboard

Product updates

Dynamics 365 release plans