Skip to main content

Notifications

Announcements

No record found.

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 Microsoft Employee

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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to create a Dialog Field with lookup that accept multi or range in Report UI Builder

    Hi Both,

    Thank you for your kind assistance. I've managed to resolve the problem.

    Again, thank you so much.

  • Blue Wang Profile Picture
    Blue Wang on at
    RE: How to create a Dialog Field with lookup that accept multi or range in Report UI Builder

    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 ().

  • Blue Wang Profile Picture
    Blue Wang on at
    RE: How to create a Dialog Field with lookup that accept multi or range in Report UI Builder

    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;
    }

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: How to create a Dialog Field with lookup that accept multi or range in Report UI Builder

    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;
    	}

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to create a Dialog Field with lookup that accept multi or range in Report UI Builder

    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
    Sergei Minozhenko 23,089 on at
    RE: How to create a Dialog Field with lookup that accept multi or range in Report UI Builder

    Hi WWwong,

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

    Check example in CfmPaymentJournalCreate* classes.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to create a Dialog Field with lookup that accept multi or range in Report UI Builder

    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,

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to create a Dialog Field with lookup that accept multi or range in Report UI Builder

    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
    Community Member Microsoft Employee on at
    RE: How to create a Dialog Field with lookup that accept multi or range in Report UI Builder

    Hi Sergei,

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

  • Verified answer
    Blue Wang Profile Picture
    Blue Wang on at
    RE: How to create a Dialog Field with lookup that accept multi or range in Report UI Builder

    Hi WWwong,

    You can refer these blog:

    d365-solutions.blogspot.com/.../d365-ax-7-multi-select-lookup-for-ssrs.html

    dynamicsaxinsight.wordpress.com/.../

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,431 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans