Showing posts with label element.args().record(). Show all posts
Showing posts with label element.args().record(). Show all posts

Friday, July 15, 2011

SubStr function - Axapta

str SubStr (str _text, int _position, int _chars)

SubStr("MyString",20,3);  // Returns ""
SubStr("MyString ",4,50);  // Returns "tring"

Monday, July 11, 2011

Create loop from an AX form DataSet - Ax 2009

Sometimes we need to loop through values at the form level. The following code loops (for loop) the SalesParmTable in the CloseOk() Form method.        


        //Create Lines
        for (localSalesParmTable = salesParmTable_ds.getFirst();
              localSalesParmTable;
              localSalesParmTable = salesParmTable_ds.getNext())
        {

              ....Implementation....
        }

Thursday, March 3, 2011

Set the Business Relationship Account in the Activities Form

Yesterday I had a requirement that said to pre-populate the Business Relationship Account in the Activities Form field Business Account upon creation of a new activity.

To do this I modified the InitValue() method within the smmActivities Data Source:

Forms > smmActivities > DataSources > smmActivities > Methods > InitValue


To do it I had to make sure that the element that was calling the form was the smmBusRelTable, then I assigned the element record to my smmBusRelTable variable. Finally, upon checking the validity of the record, I assigned the busRelTable.BusRelAccount to the busRelAccount in the smmActivities table.

The code is as follows:


THE FOLLOWING CODE GOES INTO THE FORM INIT METHOD
if (element.args().dataset() == tablenum(smmBusRelTable))
    {
        busRelTable = element.args().record();
        //businessRelationRange.value(smmBusRelTable.BusRelAccount);
    }

This Goes in the smmActivities data source initvalue().
    if(busRelTable.BusRelAccount)
    {
        smmActivities.smmBusRelAccount = busRelTable.BusRelAccount;
    }