Monday 7 May 2018

Simple Edit Method in Ax 2012

//Edit Method in ax 2012
Edit Mileage mileage(boolean set, Mileage value)
{
CarTable    carTable;
Mileage     ret;
        ;
carTable = CarTable::find(this.CarId, set);
if (set)
{
        ttsbegin;
carTable.Mileage = value;
carTable.update();
        ttscommit;
}
       else
       {
ret = carTable.Mileage;
       }

      return ret;
}

//Example 2

//Edit Method in ax 2012
public edit NoYesId IsAllowed(boolean _set, NoYesId _value)
{
    NoYesId             ret;
    int                 actualValue;
    if (_set)
    {
        if(_value == NoYes::Yes)
        {
            actualValue = 1;
        }
        ttsbegin;
        this.IsAllowedInt = actualValue;
        this.update();
        ttscommit;
    }
    else
    {
        if(this.IsAllowedInt)
        {
            ret = NoYes::Yes;
        }
    }
    return ret;
}

No comments:

Post a Comment