Wednesday, December 2, 2015

Multi-Select Lookup Control and grid filteration Using X++

1.Create a Form

2.Go to Design node and then select a StringEdit Control

3.Name the control as Multilookup - Set auto declaration to Yes to access the control using X++

4.Add a button in order to get values on button click

5.Now open the Class Declaration node of the form and write the following code into it

   SysLookupMultiSelectCtrl msCtrl;

6.Override the init method of the form and write the following code in it

Query query = new Query();

QueryBuildDataSource qbds;


//creating query to show customer account and customer name

//the query must contain only those fields that should be visible on the lookup

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



qbds = qbds.addDataSource(tableNum(DirPartyTable));




//assigning control and query to the class

msCtrl = SysLookupMultiSelectCtrl::constructWithQuery(element, MultiLookup, query);

Note :- if you are using the AOT query you can using the below code

msCtrl = SysLookupMultiSelectCtrl::construct(element, MultiLookup, queryStr(queryname));

7.Now  override the clicked method of the Button

void clicked()
    CustTrans           custtrans1;
    CustTable           custtable;
    DirPartyTable       dir;
    List                strlist   = new List(Types::String);
    ListIterator        iterator;
    container           packedList, c,v;
    int i;


    iterator = new ListIterator(strlist);
    while(iterator.more()) // Additionally, to move to the next item in a list, you must explicitly call the more and next methods if you are using a list iterator.

       //filtering the grid based on the selected customers and Trans Date.
        while select custtrans1
        where custtrans1.AccountNum ==  iterator.value()               
         && custtrans1.TransDate >= Proj_CustTrans_kkr_FromDate.dateValue()
         && custtrans1.TransDate <= Proj_CustTrans_kkr_ToDate.dateValue()

            Proj_CustTrans_kkr.CustAccount = custtrans1.AccountNum;
            Proj_CustTrans_kkr.Name = DirPartyTable::findRec(CustTable::find(custtrans1.AccountNum).Party).Name;
            Proj_CustTrans_kkr.AmountCur = custtrans1.AmountCur;
            Proj_CustTrans_kkr.TransDate = custtrans1.TransDate;
        }; // Additionally, to move to the next item in a list, you must explicitly call the more and next methods if you are using a list iterator.




No comments:

Post a Comment

How to enable the dimension fields based on the Item selected on the form.

[Form] public class KMTShipFromWarehouses extends FormRun {     InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;     /// &l...