zoukankan      html  css  js  c++  java
  • Using X++ copy the favorites from one user to another

    He favorites menu is a popular thing in Dynamics AX 2009. It has been around for quite some time now in Dynamics AX 2009, in one form or another.
    A common request that I get from users is: "Hey, I like this guy's favorites menu, can't I copy it to me own settings?'.
    The answer in standard Ax is: No, you can't. But as with almost anything in Ax: It can be done with a little modification.
    In order to be able to copy the favorites menu, you have to know where it is stored. This is done in the system table SysPersonalization, in the 'Buffer' field. We are looking for records in this table with the elementtype of UserMenu.
    This next job will copy the favorites menu from user A to user B. (If user B has a favorities menu setup, it will be lost, as it first gets deleted.)

    static void Jimmy_FavoritesCopy(Args _args)
    {
    SysPersonalization FromSysPersonalization;
    SysPersonalization ToSysPersonalization;
    UserId FromUserId
    = "Jimmy";
    UserId ToUserId
    = "Admin";
    ;
    ttsbegin;
    // step 1 - delete current favorites menu from user
    while select forupdate ToSysPersonalization
    where ToSysPersonalization.ElementType == UtilElementType::UserMenu
    && ToSysPersonalization.UserId == ToUserId
    {
    ToSysPersonalization.doDelete();
    }

    // step 2 - duplicate from user A
    while select FromSysPersonalization
    where FromSysPersonalization.UserId == FromUserId
    && FromSysPersonalization.ElementType== UtilElementType::UserMenu
    {
    ToSysPersonalization.data(FromSysPersonalization);
    ToSysPersonalization.UserId
    =ToUserId;
    ToSysPersonalization.doInsert();
    }
    ttscommit;
    }

    use at own risk

    Note: I have used the methods dodelete() and doinsert(), instead of delete() and insert(). Reason: You would run into trouble with access permissions otherwise.

  • 相关阅读:
    Step one : 熟悉Unix/Linux Shell 常见命令行 (三)
    Step one : 熟悉Unix/Linux Shell 常见命令行 (一)
    PLAN: step one
    PLAN : 入门题目 ( update )
    SZU : A11 Sequence
    SZU:B85 Alec's Eggs
    codeforces 518B. Tanya and Postcard 解题报告
    BestCoder8 1001.Summary(hdu 4989) 解题报告
    hdu 1556.Color the ball 解题报告
    codeforces 515C. Drazil and Factorial 解题报告
  • 原文地址:https://www.cnblogs.com/Fandyx/p/2095594.html
Copyright © 2011-2022 走看看