Sunday 19 October 2014

DIXF / DMF Issue with Entities

Using DIXF requires a set of versatile skills from Excel to X++. I came across this issue where I kept getting the error below every time I uploaded various entities particularly Customer.

Results. Record ('XXX') . A record with RecId 0 does not exist.
Results. Record ('XXX') . Account  does not exist.
Results. Record ('XXX') . Update has been cancelled.
This issue was caused by incorrect lincence configuration when a field was passed on and the key was not enabled. Below code can be used to clean the data in the staging on the fly.
static void CLearCustomerEntityState(Args _args)
{
    DMFCustomerEntity cust;
    int counter;
    ;
        counter = 0;
    while select forUpdate cust where cust.TransferStatus == 2
    {
        ttsBegin;
             cust.State = "";
             cust.County = "";
        cust.AccountBalance = 0;
        cust.update();
        ttsCommit;

        counter++;
    }
    info(strFmt("Cleared : %1",counter));

}

Wednesday 15 October 2014

Create Security Roles Using X++

There is times when we need to create security roles in a good number particularly to deal with workflow. The below code would do the job just well.

static void InsertSecurityRoles(Args _args)
{
SecurityRole role;
;
 ttsBegin;
  
        select forUpdate role;
        role.Name='SEC_Group'; 
        role.AOTName='SEC_Group'; 
        role.description='Description of the security role'; 
        role.insert();
 ttsCommit;

info("Groups Created");
}