Thursday, May 5, 2016

Copy one UserGroup Users list to another user group in AX

static void AXcopyUserGroupUserlist(Args _args)
{
    usergrouplist usergrouplist,ins,exitslist;
    userGroupid src,dest;
    dialogfield srcdf,destdf;
    dialog dialog;
    ;
    dialog = new dialog("copying user group's user lists ");
    srcdf = dialog.addField(typeid(userGroupid),"Source");
    destdf = dialog.addField(typeid(userGroupid),"Destination");



    if(dialog.run())
    {
        src = srcdf.value();
        dest = destdf.value();
        if(src!="" && dest !="")
        {
            ttsbegin;


            info("Copying user groups USER ID to destination user GROUP ");
            while select * from usergrouplist
            where usergrouplist.groupId == src
            {
                select exitslist where exitslist.UserId == usergrouplist.userId
                && exitslist.groupId == dest;

                if(exitslist.RecId == 0)
                {
                ins.clear();
                ins.userId = usergrouplist.userId;
                ins.groupId = dest;
                ins.insert();
                }

            }
            ttscommit;
            info("User groups has been copied!");
        }
    }
    else
    {
        info("Canceled by user");
    }


}

No comments:

Post a Comment

Sending Email using X++ Code in D365 F&O/ AX 7 in HTML fomat

  I was just researching on the emailing capabilities in D365 and found that SysINetMail, SysMailer and some of the smmOutlook classes are d...