Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Sunday, October 26, 2014

Overcome from divide by zero error in AX

Hi,

2 ways.

>>
int    a,b,c;
if(b)
    c = a / b;
else
 print " Cannot divide by zero"

OR

c  = a / minOne(b);

//it returns a itself if b is zero because minOne() returns non zero values that we passes. If it is zero then it retuns 1

Above methods is to prevent the stoppage of flow of execution.

Regards,

Saturday, October 25, 2014

Code to get multi selected records in from grid in AX

Hi,

Make that object (button) to multiselect property as "YES".
on the control (button) event method (Clicked).

void clicked()
{

     int             ListOfRecIds, i=1;
    container  contains;
    CustTable  custTableLoc; // Table_Name  that we used in as the datasource.
    super();
   
    ListOfRecIds= custTable_ds.recordsMarked().lastIndex();
    custTableLoc= custTable_ds.getFirst(1);
   
   while (custTableLoc)
    {
        contains = conIns(container, i ,custTableLoc.AccountNum)
       custTableLoc = custTable_ds.getNext();
        i++;
    }
 }
Regards,

How find size of recordsortedlist in D365/AX 2012

Hi, This is the continuity of the previous article where we are now getting the size of recordsortedlist . if(recordsortedlist.len() >1) ...