Jan 10, 2012

working with dates in axapta

Today i would like to discuss how to print the date in different formats.
have a look into the following code you will have an idea about the date formats in axapta.

static void Job1(Args _args)
{
    date currentDate = today();
    str s;
    int iEnum;
    ;
    s = date2Str
        (currentDate,
        321,
        DateDay::Digits2,

        DateSeparator::Hyphen, // separator1
        DateMonth::Digits2,
        DateSeparator::Hyphen, // separator2

        DateYear::Digits4
        );
    info("Today is:  " + s);
}

it will give the following output

/** Example Infolog output
Message (12:36:21 pm)
Today is:  2009-01-13
**/

Here the sequence parameter values must be any three digit number that contains exactly one occurrence of each digit 1, 2 and 3. The digits 1-2-3 represent day-month-year respectively. For example, 321 would produce the sequence of year, month, and day.

How to get the current database name in axapta

Axapta supports a class called SysSqlSystemInfo by using this calss we can get the current database name...

static void sqlSysName(Args _args)
{
    ;
    info(SysSQLSystemInfo::construct().getloginDatabase());
}

Delete Actions in axapta

Cascade
A cascading deletion action will delete all records in the related table, where the foreign key is equivalent to the primary key of the current table. That is, deleting the parent record will also delete the child record(s) in the related table.
This cascading will take place whether the deletion is performed in code or directly by a user through the user interface.

Restricted
A restricting delete action will raise an error message if the user tries to delete a record, where records exist in the related table where the foreign key is equivalent to the primary key of the current table.
This error will only appear if the deletion is performed through the user interface. A deletion from X++ code will be allowed to proceed and will not be cascaded to the related table. In this case the programmer should call .validateDelete() themselves prior to the call to .delete()

Cascade+Restricted
This delete action normally works as a Restricted delete action. However if the deletion is performed through X++ code, no error will be raised and the deletion will be cascaded to the related table.