Duplicating standard role through code in Axapta 2012

Hi all,

Kindly help how can I duplicate existing roles in AX 2012? let say we have Account manager and I want to create a duplicate of it through code.How it can be done. Kindly help me .



static void duplicateRole(Args _args)




TreeNode treeNode = TreeNode::findNode(#SecRolesPath + #AOTDelimiter + “SystemUser”);

TreeNode treeNodeNew;

securityRoleName roleName = ‘NewSystemUser’;

treeNodeNew = treeNode.AOTDuplicate();

treeNodeNew.AOTsetProperty(#PropertyName, roleName);



Thanks Kranthi sir.Its working fine and as expected.