web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Extending UIBuilder and using multi select lookup

(2) ShareShare
ReportReport
Posted on by 49
I am trying to add multi select field to my report
 
and I did this
 
My contract class extension
[ExtensionOf(ClassStr(CustAccountStatementExtContract)) ]
final class TRCCustAccountStatementExtContract_Extension
{
    private CustAccount MainAccount;
    private List SubMainAccounts;

    [DataMemberAttribute("MainAccount"),
     SysOperationLabelAttribute("Main Account")]
    public CustAccount parmMainAccount(CustAccount _MainAccount = MainAccount)
    {
        MainAccount = _MainAccount;
        return MainAccount;
    }

    [DataMemberAttribute("SubMainAccounts"),
    AifCollectionTypeAttribute("SubMainAccounts", Types::String),
     SysOperationLabelAttribute("Sub Main Accounts")]
    public List parmSubMainAccounts(List _SubMainAccounts = SubMainAccounts)
    {
        SubMainAccounts = _SubMainAccounts;
        return SubMainAccounts;
    }

}
My try to do the multi select lookup
[ExtensionOf(ClassStr(CustAccountStatementExtUIBuilder))]
final class DYNACustAccountStatementExtUIBuilder_Extension
{
    private DialogField MainAccountField , SubMainAccountFields;

    public void build()
    {
        contract = this.dataContractObject() as CustAccountStatementExtContract;

        MainAccountField = this.addDialogField(methodStr(CustAccountStatementExtContract, parmMainAccount), contract);
        SubMainAccountFields = this.addDialogField(methodStr(CustAccountStatementExtContract, parmSubMainAccounts), contract);

        SubMainAccountFields.lookupButton(FormLookupButton::Always);

        next build();
    }

    public void postRun()
    {
        Query                    query           = new Query();
        QueryBuildDataSource    qbdsCustTable   = query.addDataSource(tablenum(CustTable));

        qbdsCustTable.fields().addField(fieldNum(CustTable, AccountNum));

        container selectedFields = [tableNum(CustTable), fieldNum(CustTable, AccountNum)];

        SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(), SubMainAccountFields.control(), query, false, selectedFields);
        
        next postRun();
    }
}
 
Is it the correct way to do it?
 
and also I get this error when I run the report
 
  1. A control with the name 'Fld2_1_Ids' already exists on the form.
 
 
 
 
 
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    236,570 Most Valuable Professional on at
    Extending UIBuilder and using multi select lookup
    The fields are added automatically, therefore adding them again in your code (by this.addDialogField()) is wrong. Instead, get the existing fields by this.bindInfo().getDialogField() (in postBuild() or in build() below next build()).
  • Kareem Profile Picture
    49 on at
    Extending UIBuilder and using multi select lookup
    public void build()
    {
        next build();
    
        contract = this.dataContractObject() as CustAccountStatementExtContract;
        
        MainAccountField = this.bindInfo().getDialogField(
        contract,methodStr(CustAccountStatementExtContract, parmMainAccount));
        
        SubMainAccountField = this.bindInfo().getDialogField(
        contract,methodStr(CustAccountStatementExtContract, parmSubMainAccounts));
    }
    When  I tried to do this
     
    I get this error when I run the report Object reference not set to an instance of an object.

    I also tried to do it in postBuild
  • Martin Dráb Profile Picture
    236,570 Most Valuable Professional on at
    Extending UIBuilder and using multi select lookup
    When you get an error, your next step should be finding where it's thrown. Very often, you'll then understand what's wrong and you'll be able to fix it, or you'll at least be able to ask a reasonable question is a forum. Please do it now.
  • Kareem Profile Picture
    49 on at
    Extending UIBuilder and using multi select lookup
    Sadly without using (by this.addDialogField()) the parameters doesn't get added I tried to remove them and the fields got deleted by this, maybe because I am making extension of the UIBuilder class
    [ExtensionOf(ClassStr(CustAccountStatementExtUIBuilder))]
     
    public void build()
    {
    
        contract = this.datacontractobject() as custaccountstatementextcontract;
    
        mainaccountfield = this.adddialogfield(methodstr(custaccountstatementextcontract, parmmainaccount), contract);
        submainaccountfield = this.adddialogfield(methodstr(custaccountstatementextcontract, parmsubmainaccounts), contract);
    
        next build();
    }
    
    public void postRun()
    {
        next postRun();
    
        contract = this.datacontractobject() as custaccountstatementextcontract;
    
        ////Customers Name
        //SubMainAccountField   = this.bindInfo().getDialogField(contract, 
        //    methodStr(custaccountstatementextcontract, parmsubmainaccounts));
    
        SubMainAccountField.registerOverrideMethod(methodStr(FormStringControl, lookup), 
            methodStr(CustAccountStatementExtUIBuilder, subMainAccountsLookup), this);
    
        if (SubMainAccountField)
        {
            SubMainAccountField.lookupButton(2);
        }
    }
    The multi select lookup is working with this but I am getting this error

     
    1. RegisterOverrideMethod was called twice for the same object for method 'lookup'. You can only override a method once per instance.

    I've been trying to solve this for the whole day but couldn't find any solution.
  • Martin Dráb Profile Picture
    236,570 Most Valuable Professional on at
    Extending UIBuilder and using multi select lookup
    Oh, sorry, I didn't notice you have extended an existing contract.
     
    I don't think that your new idea to create a multiple-selection lookup without SysLookupMultiSelectCtrl (and using registerOverrideMethod()) is a good one. You need to find and fix the problem regarding SysLookupMultiSelectCtrl, not to throw away SysLookupMultiSelectCtrl and try code that can't ever do what you want.
     
    What happens if you return to your original code and move your code inb build() below next build().
  • Kareem Profile Picture
    49 on at
    Extending UIBuilder and using multi select lookup
     
    They are showing up but disabled as in the screenshot

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,771

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 806 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 542 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans