Alfasith AX

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

Sunday, September 22, 2013

Send task msg from current outlook in Dynamic AX


Hi,

static void AppointmentFrom
Outlook(Args _args)
 {
   COM    sysOutlookCollection;
   COM    receipiants;
   COM    collection;
   COMVariant comStartDate = new COMVariant();
   COMVariant comEndDate  = new COMVariant();
   COM    c;
   #SysOutLookCOMDEF
   #define.mapi("MAPI")
   #define.outlook("Outlook.Application")
   COM    sysOutlook;
   COM    sysOutlookNameSpace;
   COM    sysOutlookMAPIFolder;
 sysOutlook                       = new COM(#outlook);
sysOutlookNameSpace     = sysOutlook.getNamespace(#mapi);
sysOutlookNameSpace.logon();  
sysOutlookMAPIFolder    = sysOutlookNameSpace.getDefaultFolder(#OlDefaultFolders_olFolderTasks);
collection         = sysOutlookMAPIFolder.items();
 c = collection.add();
 comStartDate.date(today());
   comStartDate.time(str2Time( "12:00:00"));
   comEndDate.date(today());
   comEndDate.time(str2Time( "12:15:00"));
   c.subject("This is the subject");
   c.body("Body of that msg");
   c.save();
   if (c)
   {
     receipiants = c.Recipients();
     receipiants.add("mdalfasith@gmail.com");
     receipiants.ResolveAll();
     c.assign();
     //c.display();
     c.send();
     info("Success msg in AX");
   }
   else
   throw error("@SYS31969");
   sysOutlookNameSpace.logoff();
 } 

Thursday, September 19, 2013

Validate the contract class or SSRS parameter from code level before printing

Just add below code in contract class so that mandatory  fields like date fields can be validated by throwing the warning.

public boolean validate()
{
    boolean             isValid = true;

    if (!fromDate)
    {
        isValid = checkFailed("From Date should be entered");
    }

    if (!toDate)
    {
        isValid = checkFailed("To Date should be entered");
    }

    if (isValid && (fromDate > toDate))
    {
        isValid = checkFailed(strfmt("From Date should be less than or equal to To Date", date2StrUsr(fromDate, DateFlags::FormatAll), date2StrUsr(toDate, DateFlags::FormatAll)));
    }

    return isValid;
}

How to invoke and iterate List as Contract methods in AX 2012/ D365

Hi, Public void performContractIterate(ClassContainsListAsContract    _ListCarryClass) { List contractFieldList = new List(Types::Class); ...