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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

How to create a Dialog Field with lookup that accept multi or range in Report UI Builder

(0) ShareShare
ReportReport
Posted on by

Hi all,

In UI Report Builder, how to create a report parameter Dialog that accept multiple value. As usual the Dialog Field that I want, lets say Customer account number, the Dialog field will have Lookup from Customer Table, but I want it to be able to receive multiple or a range like this

Customer account : TEST001, TEST002, TEST99

or

Customer account : TEST001..TEST100

For the lookup creation in report UI Builder, usually I create like this

class MyrRptUIBuilder extends SrsReportDataContractUIBuilder
{
MyContract       RptContract;

public void myCustLookup(FormStringControl _lookup)
{
Query query = new Query();
QueryBuildDataSource qbds;
//QueryBuildRange qbr;
SysTableLookup sysTableLookUp;

if (_lookup != null)
{
sysTableLookUp = SysTableLookup::newParameters(tableNum(CustTable), _lookup);
sysTableLookUp.addLookupfield(fieldNum(CustTable, AccoutnNum));
qbds = query.addDataSource(tableNum(CustTable));

sysTableLookUp.parmQuery(query);
sysTableLookUp.performFormLookup();
}
}

public void postRun()
{
DialogField dlgCustomer;

RptContract = this.dataContractObject() as MyContract;
super();

dlgCustomer= this.bindInfo().getDialogField(this.dataContractObject(),methodStr(MyContract, parmCustomer));
dlgCustomer.registerOverrideMethod(methodStr(FormStringControl, lookup), methodStr(MyrRptUIBuilder , myCustLookup),this);
}

}

Thanks.

  • Sergei Minozhenko Profile Picture
    23,099 on at

    Hi WWwong,

    How you will use this parameter in report processing? For me, it looks like a query parameter is a better place for this kind of filter?

  • Verified answer
    Blue Wang Profile Picture
    Microsoft Employee on at
  • Community Member Profile Picture
    on at

    Hi Sergei,

    Yeah, I tried to tell them, but you know "client" is, they so demanding.

  • Community Member Profile Picture
    on at

    Hi Blue,

    In the first link, I tried to follow it, but under the Lookup method, I got stuck in SysLookUpMultiSelectCtrl.

    private void lookupVendor()

    {

           Query                   query = new Query();

           QueryBuildDataSource    qbd, qbdPerson;

           TableId     multiSelectTableNum = tableNum(VendTable);

           container   selectedFields      = [multiSelectTableNum, fieldName2id(multiSelectTableNum, fieldStr(VendTable, AccountNum))];

           qbd = query.addDataSource(tableNum(VendTable));

           qbd.addSelectionField(fieldNum(VendTable, AccountNum));      

           qbd.fields().dynamic(NoYes::No);

           qbd.fields().clearFieldList();

           qbd.fields().addField(fieldNum(VendTable, AccountNum));

           qbd.addRange(fieldNum(VendTable, HRRSPayrollVendor)).value(queryValue(NoYes::Yes));

           qbdPerson = qbd.addDataSource(tableNum(DirPartyTable));

           qbdPerson.fields().dynamic(NoYes::No);

           qbdPerson.fields().clearFieldList();

           qbdPerson.fields().addField(fieldNum(DirPartyTable, Name));

           qbdPerson.relations(true);      

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

    }

    After the statement this.dialog() there is no access to dialogForm().FormRun()

    Do you know where is that come from ?

    I think the blog is not complete, also what should happened in Report Data Provider Class ? In that UIBuilder class, there is a variable VendorList which is not used anywhere in the sample.

    Thanks,

  • Community Member Profile Picture
    on at

    Hi,

    .. and for the 2nd link :

    dynamicsaxinsight.wordpress.com/.../

    SysLookupMultiSelectGrid function is changed because right now it needs 5 parameters whereas in that blog it is 4 parameter.

    .. for the 1st link, is it possible because the sample, the report parameter was calling from a form, that's why it has this.dialog().dialogForm().formRun(), which is in my case is not.

    Please advice.

    Thanks,

  • Sergei Minozhenko Profile Picture
    23,099 on at

    Hi WWwong,

    You can always search by cross-referencies by certain class.

    Check example in CfmPaymentJournalCreate* classes.

  • Community Member Profile Picture
    on at

    Hi Sergei,

    Yes, tried so, but as usual, the existing is too complicated for me to understand. However with the 1st link :

    d365-solutions.blogspot.com/.../d365-ax-7-multi-select-lookup-for-ssrs.html managed to Build sucessfully, I guess I can just type in.

    But ran to a runtime error, saying "Contract class list should have a public constructor with no arguments"

    Here are my two classes :

    [ DataContractAttribute,
    SysOperationContractProcessingAttribute(classstr(MyRptUIBuilder))]
    class MyRptContract
    {

    List customerAccount;

    [ DataMemberAttribute("CustomerAccount"),
    SysOperationLabelAttribute(literalStr("@SYS16716")),
    SysOperationDisplayOrderAttribute('1')
    ]
              public List parmCustAccount(list _customerAccount = customerAccount)
              {        
                    customerAccount = _customerAccount;
                    return customerAccount;
               }

    }

    class MyRptUIBuilder extends SrsReportDataContractUIBuilder
    {
            MyRptContract RptContract;

            private DialogField dlgCustomerAccount;
            List customerList;


    public void postBuild()
    {
          super();

          RptContract = this.dataContractObject();


           dlgCustomerAccount = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(MyRptContract, parmCustAccount));


    }


    public void paymCustomerLookup()
    {
          Query query = new Query();
          QueryBuildDataSource qbds;

          TableID multiSelectTable = tableNum(CustCustomerBaseEntity);
          container selectedCust = [multiSelectTable, fieldName2Id(multiSelectTable, fieldStr(CustCustomerBaseEntity, CustomerAccount))];


          qbds = query.addDataSource(tableNum(CustCustomerBaseEntity));

          SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().FormRun(), dlgCustomerAccount.control(),
                                Query, false, selectedCust);


    }

    public void postRun()
    {
              this.paymCustomerLookup();
    }

    }

    If based on the error saying about List, it does related to the variable List declared in UIBuilder that I cannot find the usage in that code (also in that blog)

    Thanks,

  • Sergei Minozhenko Profile Picture
    23,099 on at

    Hi WWwong,

    To resolve the error try to specify AifCollectionTypeAttribute for List member

    	[ DataMemberAttribute("CustomerAccount"),
    	SysOperationLabelAttribute(literalStr("@SYS16716")),
    	SysOperationDisplayOrderAttribute('1'),
    	AifCollectionTypeAttribute('_customerAccount',Types::String),
        AifCollectionTypeAttribute('return',Types::String)
    	]
    	public List parmCustAccount(list _customerAccount = customerAccount)
    	{        
    		customerAccount = _customerAccount;
    		return customerAccount;
    	}

  • Blue Wang Profile Picture
    Microsoft Employee on at

    HI Wwwong,

    In the second link, the Contract Class section has used List.

    class MAKParametersContract
    {
        List  custAccountList;
    }
    
    [
        DataMemberAttribute("custAccountList"),
        AifCollectionTypeAttribute("custAccountList", Types::String),
        SysOperationLabelAttribute(literalStr("Customers"))
    ]
    public List parmCustAccountList(List _custAccountList = custAccountList)
    {
        custAccountList = _custAccountList;
    
        return custAccountList;
    }

  • Blue Wang Profile Picture
    Microsoft Employee on at

    HI WWwong,

    The first link uses SysLookupMultiSelectCtrl :: constructWithQuery (), which defines 5 parameters, but the last two are optional parameters, if you do n’t provide a value it gets the default.

    041245.PNG

    The second link uses SysLookupMultiSelectGrid :: lookup ().

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
Martin Dráb Profile Picture

Martin Dráb 539 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 366 Super User 2026 Season 2

#3
CU-1234529-002 Profile Picture

CU-1234529-002 197

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans