Wednesday, 18 December 2013

Group Specific Lookup in dynamics Ax


Step 1: Create a field with Name “ParentLevel” in VendTable string type. Create a form “VendGroupLookup” and drag- drop “VendTable” and “VendGroup” table in data source and in the VendTable data source set property  “JoinSource - VendtGroup”. Create Designs like figure 1.


Figure 1: Create VendGroupLookup form.

Step2 – create a method on “VendTable”

 public static void lookupVendorGroup(FormControl _callingControl, VendGroupId    _vendGroup)    
{
    Query                   query;
    QueryBuildDataSource    qbds;
    QueryBuildRange         qbr;
    SysTableLookup          lookup;
    ;
    query = new Query();
    lookup = SysTableLookup::newParameters(tablenum(VendTable),_callingControl);
    qbds = query.addDataSource(tablenum(VendTable));
    lookup.addLookupField(fieldnum(VendTable, AccountNum),true);
    lookup.addLookupField(fieldnum(VendTable, Name));
    lookup.addLookupField(fieldnum(VendTable, VendGroup));
    qbr = qbds.addRange(fieldnum(VendTable, VendGroup));
    qbr.value(queryvalue(_vendGroup));
    lookup.parmQuery(query);
    lookup.performFormLookup();
}

Step3 – Go to VendGroupLookup form and go to VendTable data source and go to new created field “ParentLevek” and override lookup method with this code:-

public void lookup(FormControl _formControl, str _filterStr)
    {

    ;
    VendTable::lookupVendorGroup(_formControl, VendGroup.VendGroup);
    super(_formControl, _filterStr);
}

Finally, Open the “VendGroupLookup” form and when you select group “30” you will get record as lookup that has group “30” according to figure 2.
Figure 2: Result.

No comments:

Post a Comment

SQL/SSRS Interview questions I thought of blogging some SQL/SSRS interview questions.

Below are some. I will add more, when I complete the compilation 1. What is OLTP(Online Transaction Processing)? OLTP stands ...