Restrict non-admin users to open multiple sessions in AX 2012

Copy Paste the Following Code in startupPost method of info class in AOT void startupPost() { xSession session; SysClientSessions SysClientSessions; UserId currentUserId; int counter;   currentUserId = curUserId(); if (!isSystemAdministrator())// Allow Admin User to login multiple time { while select SysClientSessions where SysClientSessions.userId == currentUserId && SysClientSessions.clientType == 0 { session = new xSession(SysClientSessions.SessionId, true); […]

Hide Export file format : SSRS Report Viewer using X++

Sample Code to hide the Export option from SSRS report viewer using x++   STEP 1: First We need to add the reference “Microsoft.ReportViewer.WinForms” in AOT STEP 2:  Add the below code into the Form “SRSReportViewer’   public void hideExportButton()public void hideExportButton() { System.Windows.Controls.UIElementCollection children;    Microsoft.Reporting.WinForms.ReportViewer reportViewer; children = _axreportViewer_control.get_Children();    reportViewer = children.get_Item(0); reportViewer.set_ShowExportButton(false); […]

Check physical existance of file

One of many ways to check file existance on folder for Client side :  WinAPI::fileExists(_fileName); And for Server side System.IO.FileInfo   fileInfo; new InteropPermission(InteropKind::ClrInterop).assert(); fileInfo = new System.IO.FileInfo(_fileName); return fileInfo.get_Exists();

Run RDP based report from Code & passing parameter using Data contract

Bsic Code to run RDP based report using x++ and passing parameters to data contract. SrsReportRunController controller = new SrsReportRunController(); VendSOAReportTmpContract rdpContract = new VendSOAReportTmpContract (); SRSPrintDestinationSettings settings;   controller.parmReportName(ssrsReportStr(VendSOATmpReport,PrecisionDesign)); controller.parmShowDialog(false); rdpContract.parmVendAccount(VendPurchOrderJour.OrderAccount); controller.parmReportContract().parmRdpContract(rdpContract); controller.startOperation();

Step name of Workflow

Below is the reference sample code to get the workflow step name. public display str 25 stepName(PurchReqTable _purchReqTable) { container con; PurchReqTable purchReqTable; PurchReqTableHistory purchReqTableHistory; WorkflowTrackingStatusTable workflowTrackingStatus; WorkflowTrackingTable workflowTracking; utcdatetime validDate = DateTimeUtil::utcNow(); WorkflowStepName stepName; TransDate stepSinceDate; PurchReqRequisitionStatus status; TransDate statusSinceDate; RefRecId workflowTrackingStatusRecId; RefRecId workflowStepRecId; UserInfo userInfo; WorkflowTrackingTable workflowTrackingLocal,workflowTrackingLocal2,workflowTrackingLocal3; WorkflowStepTable workflowstepTable; RefRecId _purchReqTableRecId = _purchReqTable.RecId; […]