Alfasith AX

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

Saturday, May 24, 2014

Look up filter using enum value in Dynamic AX

Hi,

void lookupJobId(FormControl control)
{
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource;
    QueryBuildRange         queryBuildRange;
    SysTableLookup          sysTableLookup;
    ;

    //Create an instance of SysTableLookup with the form control passed in
    sysTableLookup = SysTableLookup::newParameters(tablenum(InventTable), this);

    //Add the fields to be shown in the lookup form
    sysTableLookup.addLookupfield(fieldnum(InventTable, ItemId), true);
    sysTableLookup.addLookupMethod(tablemethodstr(InventTable, ItemName), false);

    //create the query datasource
    queryBuildDataSource = query.addDataSource(tablenum(InventTable));
    queryBuildRange = queryBuildDataSource.addRange(fieldnum(InventTable    ,ABCValue));
    queryBuildRange.value(enum2str(ABC::A)); //Example of Enum value

    //add the query to the lookup form
    sysTableLookup.parmQuery(query);

    // Perform lookup
    sysTableLookup.performFormLookup();
}
/***************************************************************/
If the filter with reference to the enum field already existing in form then.

void lookupJobId(FormControl control)
{
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource;
    QueryBuildRange         queryBuildRange;
    SysTableLookup          sysTableLookup;
    ;

    //Create an instance of SysTableLookup with the form control passed in
    sysTableLookup = SysTableLookup::newParameters(tablenum(InventTable), this);

    //Add the fields to be shown in the lookup form
    sysTableLookup.addLookupfield(fieldnum(InventTable, ItemId), true);
    sysTableLookup.addLookupMethod(tablemethodstr(InventTable, ItemName), false);

    //create the query datasource
    queryBuildDataSource = query.addDataSource(tablenum(InventTable));
    queryBuildRange = queryBuildDataSource.addRange(fieldnum(InventTable    ,ABCValue));
//Direct filter for enum ABC::A
    queryBuildRange.value(enum2str(ABC::A)); //Example of Enum value
//else
//consider the enum fields is stored in header table as HeaderTableName.EnumField
//Make sure that EnumField should be ABC enum

    queryBuildRange.value(enum2str(str2enum(ABC,HeaderTableName.EnumField)));

    //add the query to the lookup form
    sysTableLookup.parmQuery(query);

    // Perform lookup
    sysTableLookup.performFormLookup();
}


Regards,

Upload image in to form / Application photo in Dynamic Ax

Hi,

// Use this below code in clicked method for your button placed in form.
str filename;
FileNameFilter filter = ['JPG files','*.jpg'];
Bindata binData;
Image signatureImage = new Image();

super();

filename = Winapi::getOpenFileName(element.hWnd(), filter, '', "Upload your image", '', '');

binData = new BinData();

if (binData.loadFile(filename))
{
    signatureImage = binData.getData();
    WindowField.image(signatureImage); // WindowField - is the window field and make it auto declaration  : Yes
    WindowField.widthValue(signatureImage.width());
    WindowField.heightValue(signatureImage.height());
    element.resetSize();
    element.unLock();
}
Note:  this code stows the record but not stores the record in table.

Regards,

Get a table ID in SQL - D365

Hi select ID from SysTableIdView where  SysTableIdView .Name = 'CustTable' Regards,