Alfasith AX

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

Monday, September 23, 2013

Job to save the SSRS in PDF at given location in Dynamic AX

Hi,
static void SaveSSRSasPdfCode(Args _args)
{
     SrsReportRun srsReportRun;

    srsReportRun = new SrsReportRun("ReportName.PrecisionDesign1");

    srsReportRun.init();
    srsReportRun.reportCaption("ReportName.PrecisionDesign1");
    //Parameter to be passed
    srsReportRun.reportParameter("TableNameused").value("Parameter");
    srsReportRun.showDialog(false);

    // Print to a file as ur name and location in HTML/PDF format.
    srsReportRun.printDestinationSettings().printMediumType(SRSPrintMediumType::File);
    srsReportRun.printDestinationSettings().fileFormat(SRSReportFileFormat::PDF);
    srsReportRun.printDestinationSettings().overwriteFile(true);
    srsReportRun.printDestinationSettings().fileName(@"C:\UrReportName.pdf");

    if( srsReportRun )
    {
        srsReportRun.executeReport();
    }
}

Sunday, September 22, 2013

Job to run reports without knowing the used class names in Dynamic AX

static void PrintSSRSthroughCode(Args _args)
{
    SrsReportRun srsReportRun;
    srsReportRun = new SrsReportRun ("ReportName.PrecisionDesign1");
    srsReportRun.init();
    srsReportRun.reportCaption("ReportName.PrecisionDesign1");
    // set parameters
    srsReportRun.reportParameter("TableName").value("Parameter");
    // Dialog for failure (if)
    srsReportRun.showDialog(false);
    if( srsReportRun )
    {
             srsReportRun.executeReport();
    }
}

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;
}

Tablix headers not repeating in SSRS

Hi,
To repeat tablix header through out the ssrs (all pages)
1. In the grouping pane, make sure to turn on advanced mode (click on the small black down arrow on the far right of the grouping pane)
2. Select the corresponding (Static) item in the row group hierarchy
3. In the properties grid, set RepeatOnNewPage to true
4. KeepwithGroup to After



Monday, September 16, 2013

what is the difference between Hidden and Internal in Parameter visibility ? in SSRS

Hi,
let me say you Develop a Report which has a parameter as  User!userID.Value (Named as EmployeeID in Reports)  to Filter your Data in the Reports and this is captured when user logs into Report Manager.
Case 1:
If you have this EmployeeID  as Internal you cant change this Value by passing this Value in URL.
Case 2:
If you have this EmployeeID  as Hidden and Deployed it..you can OverRide User!userID.Value by passing this Value in URL Like this ..
http://server/reportserver?/Sales/Northwest/Employee Sales Report&rs:Command=Render&EmployeeID=1234
Employee 1234 can pass 1235 and see his Data which will be security threat.
Hope this Clarifies your Doubt.

Friday, September 13, 2013

jumpref() in Dynamic AX

Hi,

public void jumpRef()
{
Args args = new Args();
PurchTable     purchTable; // that we are using not in the datasource list or it can be
;

args.caller(this);
purchTable= PurchTable::find(purchTable.PurchID);
Args.record(purchTable);

new MenuFunction(menuitemdisplaystr(purchTable), MenuItemType::Display).run(args); //menu item name of that form that is to refer
}

Friday, September 6, 2013

Validate an enum in Dynamic AX

Validate an enum

 if(NetOccupied.valueStr() == enum2str(NetOccupied::Vacant))
        CreateReservation.enabled(true);
    else
        CreateReservation.enabled(false);

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) ...