Showing posts with label Rasheed. Show all posts
Showing posts with label Rasheed. Show all posts

Dynamics AX : Send Alerts (email) to Multiple Users – Mohammed Rasheed


Alerts are one of the key features that Dynamics AX has to offer.. they are easy to setup, administer and maintain (especially with the new batch framework in Dynamics AX 2009).

However, the fact that an alert can only be setup to ‘alert’ (or inform) 2 users (the user setting up the alert and the user assigned in the ‘Alert who’ section) is quite restrictive.. as in a fast moving business (retail for example) it’s essential that multiple users are kept updated with crucial business activity. Users like information to be pushed to them, no one like hunting around the system to find out what changed and who made the change, etc etc..

I wrote a project which will enable Dynamics ax users to configure alerts that can be distributed to multiple users at the same time.

clip_image001

So, as you can see from the above pic, I added a new button to the Alert setup form, which lets you select the list of users that need to alerted when the event occurs

clip_image002

The person configuring the alert will simply have the select the other users that need to be alerted.

Note: its worth pointing out that this new functionality (and also base Dynamics AX alerts) use the email address that is configured in the user options (Tools > Options).

The following are the list of objects that were created/modified in this project.

clip_image003

Development Environment:

Kernel : 5.0.593.0

Appl: 5.0.593.0

Click here to download the project.

Note: I would like to point out that this is totally untested code, and there are no warranties or guarantees that I or my company provide on the usage of this code... this code was written to show one of the many ways in which Dynamics AX functionality can be extended and was not meant to be used in a production environment

Have a great day!

- Mohammed Rasheed

http://www.dynamic-ax.co.uk/


View the original article here

5:06 AM by Jawaan · 3

Dynamics AX: Counting Lines of Code – Mohammed Rasheed


It recently downed upon me that I do not have an account of the number of lines of code I have written on my vpc (my Dynamics AX Playground!!).... Unfortunately I could not find an easy way to get an accurate count of the lines of code I wrote.. Hence i wrote some more code :)

Its like writing code to count code!!

Hope this is of help to others out there.. asking themselves the same question.

class mrCountLinesOfCode

{

Map axTypeCount;

Map mrTypeCount;

MapEnumerator axEnumerator;

MapEnumerator mrEnumerator;

str fullPath;

int pos;

int total;

int linesOfCode;

}

void run()

{

TreeNodeiterator tempNodeIterator;

TreeNodeiterator treeNodeIterator;

TreeNodeiterator rootNodeIterator;

TreeNodeiterator childNodeiterator;

str type;

TreeNode treeNode;

TreeNode rootNode;

TreeNode childNode;

TreeNode tempNode;

;

#AOT

rootNode = TreeNode::rootNode();

rootNodeIterator = rootNode.AOTiterator();

rootNode = rootNodeIterator.next();

axTypeCount = new Map(types::String,types::Integer);

mrTypeCount = new Map(types::String,types::Integer);

while(rootNode)

{

type = rootNode.treeNodeName();

rootNodeIterator = rootNode.AOTiterator();

childNode = rootNodeIterator.next();

childNodeIterator = childNode.AOTiterator();

treeNode = childNodeIterator.next();

while(childNode)

{

tempNode = treeNode;

tempNodeiterator = tempNode.AOTiterator();

while(treeNode)

{

// loop till you get to a leaf node - as methods are leafs

while(treeNode.AOTchildNodeCount() > 0)

{

if(treeNode.AOTiterator().next().AOTchildNodeCount()> 0)

treeNode = tempNodeiterator.next();

if(!treeNode)

treeNode = tempNode;

tempNode = treeNode;

treeNode = treeNode.AOTiterator().next();

if(!treeNode)

treeNode = tempNode;

}

// so we found a Lefe. check if its a method

if(sysTreeNode::hasSource(treeNode))

{

tempNodeiterator = tempNode.AOTiterator();

while(treeNode)

{

treeNode = tempNodeiterator.next(); // iterate first.

this.setCount(treeNode,type);

}

treeNode = tempNodeiterator.next();

if(!treeNode)

{

treeNode = childNodeIterator.next();

if(!treeNode)

{

childNode = rootNodeIterator.next();

childNodeIterator = childNode.AOTiterator();

treeNode = childNodeIterator.next();

}

tempNode = treeNode;

tempNodeiterator = tempNode.AOTiterator();

}

}// end if Has Source

else

treeNode = tempNodeiterator.next(); // leaf is not a method.. hence move to the next node

}

//childNode = rootNodeIterator.next();

treeNode = childNodeIterator.next();

if(!treeNode)

{

childNode = rootNodeIterator.next();

while(childNode && !this.checkIfNodeMightHaveCode(childNode.sysNodeType()))

{

childNode = rootNodeIterator.next();

}

if(childNode)

{

childNodeIterator = childNode.AOTiterator();

treeNode = childNodeIterator.next();

}

}

}

childNode = rootNodeIterator.next();

rootNode = childNode;

}// end root while

this.printitOut();

}

void setCount(treeNode _treeNode,str _type)

{

int tempLines;

;

fullPath = sysTreeNode::getPath(_treeNode);

pos = 0;

pos = strScan(fullPath,'\mr',1,strlen(fullPath)); //i always prefix any new elements i create with MR

tempLines = this.getLinesOfCode(_treeNode.AOTgetSource());

if(tempLines > 4)

{

if(pos)

this.countMrLines(tempLines,_type);

else

this.countAXLines(tempLines,_type);

}

}

int getLinesOfCode(Source _source)

{

Source tmpSource;

Line line;

int ptr;

int numberOfLines;

;

if (_source)

{

tmpSource = _source;

while (tmpSource)

{

line++;

ptr = strfind(tmpSource, '\n', 1, maxint());

if (!ptr)

{

ptr = strlen(tmpSource);

}

numberOfLines++;

tmpSource = strdel(tmpSource, 1, ptr);

}

}

return numberOfLines;

}

int getLinesOfCode(Source _source)

{

Source tmpSource;

Line line;

int ptr;

int numberOfLines;

;

if (_source)

{

tmpSource = _source;

while (tmpSource)

{

line++;

ptr = strfind(tmpSource, '\n', 1, maxint());

if (!ptr)

{

ptr = strlen(tmpSource);

}

numberOfLines++;

tmpSource = strdel(tmpSource, 1, ptr);

}

}

return numberOfLines;

}

void countMrLines(int _lines,str _type)

{

;

linesOfCode = 0;

if(mrTypeCount.exists(_type))

linesOfCode = mrTypeCount.lookup(_type);

linesOfCode += _lines;

mrTypeCount.insert(_type,linesOfCode);

}

boolean checkIfNodeMightHaveCode(int _sysNodeType)

{

;

#TreeNodeSysNodeType

switch(_sysNodeType)

{

case #SysNodeTypeTableCollection :

case #SysNodeTypeSystemEnum :

case #NT_DBCOLLECTIONLIST :

case #NT_DBFIELDGROUPLIST :

case #NT_DBENUMLIST :

case #NT_DBREFERENCELIST :

case #NT_CONFIGURATIONKEYLIST :

case #NT_SECURITYKEYLIST :

case #NT_DBLICENSECODELIST :

case #NT_MENU :

case #NT_DBLICENSECODE :

case #NT_CONFIGURATIONKEY :

case #NT_SECURITYKEY :

case #NT_TYPE :

case #NT_REFERENCE :

case #NT_PERSPECTIVE :

case #NT_PERSPECTIVEFIELDLIST :

return false;

default:

return true;

}

// just in case

return true;

}


View the original article here

6:46 PM by Jawaan · 1

About Me