Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Wednesday, June 19, 2013

How to select multiple selected values (records) from lookup in Dynamics AX - Multi select lookup in Dynamic AX 2012

Hi,

1. In the ClassDeclaration of the form write the below code.

public class FormRun extends ObjectRun
{
    SysLookupMultiSelectCtrl      LookupMultiSelectCtrl;
}

2Override the init method of the form and place the below code

public void init()
{
    super();
    // AccountNum- Name of control on which you want a lookup.
   // CustTableQry- Query to get the lookup data
    LookupMultiSelectCtrl= SysLookupMultiSelectCtrl::construct(element, AccountNum, querystr(CustTableQry));
}

sample image of another look up snap.
That's it, Now let's see how the selected rows are returned from the lookup.


On clicking the Ok button all the selected values are returned in the String control. 


To get the values and RecId of the selected rows, simply override the modified method of the accountNum and add the below code.

public boolean modified()
{
    boolean ret;
    container contain,contain1;
    int i;
    ret = super(); 
    if (ret)
    {
        contain = LookupMultiSelectCtrl.get();  // get RecIds of the selected rows
        contain1 = LookupMultiSelectCtrl.getSelectedFieldValues(); // get actual value of the selected rows

        for (i = 1; i <= conLen(contain);i++)
        {
            info(conPeek(contain,i));
            info(conPeek(contain1,i));
        }
    }

    return ret;
}

Regards,

No comments:

Post a Comment

How find size of recordsortedlist in D365/AX 2012

Hi, This is the continuity of the previous article where we are now getting the size of recordsortedlist . if(recordsortedlist.len() >1) ...