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); […]

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; […]

Enable Modified by and Created by on ALL Parameters tables

Handy Code to have , Can be use to change any of the property of a table also just with the slightest change.   static void Waj_EnableProperties(Args _args) { SysDictTable dictTable,sysDictTable; TreeNode node; #AOT Name name; TreeNode treeNode; str indexName; #Properties ; treeNode = TreeNode::findNode(#TablesPath); treeNode = treeNode.AOTfirstChild(); while (treeNode) { name = treeNode.AOTname(); sysDictTable = […]

Create Default dimension using x++

The following job will get a DimensionAttributeValueSet record ID base on the a set of dimension values.   static void CreateDefaultDimensions(Args _args) { PurchTable purchTable; DimensionAttributeValueSetStorage valueSetStorage = new DimensionAttributeValueSetStorage(); DimensionDefault result; int i; DimensionAttribute dimensionAttribute; DimensionAttributeValue dimensionAttributeValue; // Note that “Item” is not one of the default dimension, // but DimensionAttributeValueSetStorage will handle it […]