Replace \ Delegate Workflow User

With this piece of Code we can delegate Workflow from One User to another Using X++

Here I am taking example of Purchase Requistion


static void waj_replaceWorkflowUser(Args _args)
{
workflowtrackingstatustable workflowtrackingstatustable;
workflowtrackingtable workflowtrackingtable;
PurchReqTable purchreqTable;
WorkflowWorkItemTable workItem;
WorkflowStepTable workFlowStepTableSequence, workFlowStepTable;
WORKFLOWTRACKINGCOMMENTTABLE WORKFLOWTRACKINGCOMMENTTABLE;
purchreqTable = purchreqTable::findPurchReqId('PR-010454');
select workItem order by RecId desc
where workItem.RefTableId == tableNum(purchReqTable) &&
workItem.RefRecId == purchreqtable.recid &&
workItem.Status != WorkFlowWorkItemStatus::Completed &&
workItem.UserId == 's.Wajahat'; // slect user to replace
{
info(strFmt('%1', workItem.RefRecId));
}

WorkflowWorkItemActionManager::dispatchWorkItemAction(workItem,’Delegated’,’Ali’,WorkflowWorkItemActionType::Delegate,’PurchReqDelegate’,false);
}

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 = SysDictTable::newTableId(treeNode.applObjectId());

if ((sysDictTable.tableGroup() == tableGroup::Parameter ||
sysDictTable.tableGroup() == tableGroup::Group) &&
!sysDictTable.isMap() &&
!sysDictTable.isTmp() &&
!sysDictTable.isView() &&
sysDictTable.enabled())
{

node = SysDictTable.treeNode();
node.AOTsetProperty(#PropertyCreatedBy, #PropertyValueYes);

node.AOTsetProperty(#PropertyCreatedDateTime, #PropertyValueYes);
node.AOTsetProperty(#PropertyModifiedBy, #PropertyValueYes);
node.AOTsetProperty(#PropertyModifiedDateTime, #PropertyValueYes);

node.AOTsave();

node.treeNodeRelease();
node = null;

}

}

}

Create Ledger dimension from string values

1 – By using the below code one can create ledger dimesion recId using X++
Combination of Main Account and DimensionValue

container offsetAccount;

RefRecId ledgerDimension;

offsetAccount = [‘11850000’, ‘11850000’, 3, ‘Department’, ‘101’, ‘Customer’,‘Cus-101’, ‘Vendor’, ‘Vend-101’];
//[MainAccount,MainAccount, NoOfDimensions, DimensionName, value]

ledgerDimension = AxdDimensionUtil::getLedgerAccountId(offsetAccount);

2 – Create Ledger dimension from main account (default account) and default dimension

The DimensionDefaultingService::serviceCreateLedgerDimension() method can be used to create ledger dimension from main account and default dimension.

JournalTrans.LedgerDimension = DimensionDefaultingService::serviceCreateLedgerDimension(_defaultAccount,
JournalTrans.DefaultDimension);

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 gracefully
container conAttr = [“Project”, “Vendor”]; // Dimensions
container conValue = [“1001”, “Ven-0046”]; //  respective Values
str dimValue;

purchTable = purchTable::find(‘000471’);

for (i = 1; i <= conLen(conAttr); i++)
{
dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));

if (dimensionAttribute.RecId == 0)
{
continue;
}

dimValue = conPeek(conValue,i);

if (dimValue != “”)
{
// The last parameter is “true”. A dimensionAttributeValue record will be created if not found.
dimensionAttributeValue =
dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true);

// Add the dimensionAttibuteValue to the default dimension
valueSetStorage.addItem(dimensionAttributeValue);
}
}

result = valueSetStorage.save();
purchTable.selectForUpdate(true);
ttsBegin;
purchTable.DefaultDimension = result;
purchTable.doUpdate();
ttsCommit;
}

Get Comments of a Workflow

We can use this sample code to get the workflow comments on particular Record. Project budget is my desired table  . you can replace ProjBudget to any other table on which you want to get the entered comments.

workflowcomment

while select WORKFLOWTRACKINGSTATUSTABLE where WORKFLOWTRACKINGSTATUSTABLE.ContextRecId == projBudget.RecId  //
&& WORKFLOWTRACKINGSTATUSTABLE.ContextTableId == tableNum(ProjBudget)
{

while select WORKFLOWTRACKINGTABLE where WORKFLOWTRACKINGTABLE.WorkflowTrackingStatusTable == WORKFLOWTRACKINGSTATUSTABLE.RecId
{
while select WORKFLOWTRACKINGCOMMENTTABLE
where WORKFLOWTRACKINGCOMMENTTABLE.WorkflowTrackingTable == WORKFLOWTRACKINGTABLE.RecId

{

}

}

Go to origin \ Custom button on Info

Just a quick code to add a button on InfoLog to facilitate user to go directly on the respective message record.

OutPut: 

rfq-img

 

Code :

img-2

 

SysInfoAction_MenuFunction        sysInfoAction; //Class which we have to use to create a Button.
purchRFQCaseTable       purchRFQCaseTable; // Declaration of buffer
purchRFQCaseTable = purchRFQCaseTable::find(‘RFQ-0001’);

sysInfoAction = SysInfoAction_MenuFunction::newMenuItem(menuitemDisplayStr(PurchRFQCaseTable),MenuItemType::Display); // here we create a button Link with the menu Item of the form to open on click event
sysInfoAction.parmCallerBuffer(purchRFQCaseTable); //passing buffer on the form
info (strfmt(“@SYS107925″, purchRFQCaseTable.rfqCaseId),”, sysInfoAction); // creating info with desired button

 

 

 

Process Industries Add-On for Microsoft Dynamics AX 2009

Recently  I got a requirement to install PI 2009 on one of my client. What I figured is the sequence of installation is very important

Here are the steps to follow:

1. Install AX2009 RTM (SYS layer)
2. Install SP1 (SYP layer)
3. Install GLS layer if needed
4. Install Process Industries 5.1.3.1 (BUS layer (compatible with existing GLS))
5. Install RU7 (SYP (+ GLP layer))
6. Install PI BUP layer (specific to localization)
7. Open AX client and run Installation Checklist

 

BUP layers Installation file Download link is here

 

Hope this will save Some on time 🙂