Popular Posts

Thursday 30 June 2011

Pack & UnPack


Pack and unpack
Pack
this method is a standard method inherited from RunBase. It is used to save
the values that the user selects and store them until the next time the user executes
the class.
Public container pack ()
{
return [#CurrentVersion, #CurrentList];
}

===
unpack
Standard method inherited from RunBase and used to fetch the values that the user
selected the previous time he executed the class.
public boolean unpack(container packed Class)
{
Version version = RunBase::getVersion(packedClass);
;
switch (version)
{
case #CurrentVersion:
[version, #CurrentList] = packedClass;
break;
default:
return false;
}
return true;
}

Indexes


Indexes:
                 In unique index u put in 2 or more fields it validates 2 fields and 2 rows are same it shows error otherwise if one filed allows duplicate values.

Delete Actions


Delete Actions:
1.       Cascade.
2.       Restricted.
3.       Cascade + Restricted.
1. Cascade:
If you delete the record in parent table the relating records in the child table will automatically deletes.
2. Restricted:
                                If u deletes the records in parent table there is an error shown. There is a dependent in the child table.
3. Cascade + Restricted:
                Setting the Delete Action property to Cascade + Restricted extends the functionality of the table's validate Delete and delete methods.
As a result, super (), in validate Delete, ascertains whether records exist on related tables. Whether deleting records from forms or X++, if validate Delete returns false, the primary record isn't deleted and the cascading delete isn't performed. You should first delete the records in the related table before deleting the primary record.

Filters


If u want filter the fields based on ID’s in the grid level
GoàForm’s init method àpaste the following code below super
TVPurchRequirmentSheet_DS.query().dataSourceTable(tablenum(TVPurchRequirmentSheet)).addRange(fieldnum(TVPurchRequirmentSheet,SalesId))
                       .value(QueryValue(nestingTable.SalesId));

Copy data form one table to another


Copy of the data from one table to another Table:-
Insert_recordset copyOfStudents (ID, Name, ClassName) àhere where the data is copied
        Select ID, Name, ClassName from students where students.ID<=10;  à here the source table.

Display & Edit methods in ax


Display Method:
                Take the new method in a table
display Name names()
{
    CustTable   custTable;
    ;
    return  CustTable::find(this.CustAccount).Name;
}
Then drag that method into the grid and set data source properties. In that field is non-editable.

Edit Method:
                Take the new method in the table
edit Name name(boolean _set , Name _name)
{
    Name    name    = _name;
    CustTable   custTable;
    ;
    if(_set)
    {
        if(name)
        {
            ttsbegin;
            custTable   = CustTable::find(this.CustAccount,true);
            custTable.Name  = name;
            custTable.update();
            ttscommit;
        }
    }
    else
    {
        name    = CustTable::find(this.CustAccount).Name;
    }
    return name;
}
Then drag that method into the grid and set data source properties. In that field is user edit it and accept the values to the user and save it CustTable.