Dynamics Axe:任何记录更改时发出警报

发布于 2024-10-04 13:51:12 字数 159 浏览 1 评论 0原文

当供应商表中的任何字段发生更改(以及创建/删除记录时),我想在 Axe 中发送警报。

在警报中,我想包含以前的值和当前的值。

但是,您似乎无法在表中的任何字段发生更改时设置警报,而是需要为每个字段设置警报?!我希望我是错的。

我怎样才能将此通知发送给一群人

I want to send an alert in Ax, when any field in the vendor table changes (and on create/delete of a record).

In the alert, I would like to include the previous and current value.

But, it appears that you can't set alerts for when any field in a table changes, but need to set one up for EVERY FIELD?! I hope I am mistaken.

And how can I send this notification to a group of people

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

他是夢罘是命 2024-10-11 13:51:12

我创建了一个带有静态方法的新类,我可以轻松地从任何 .update() 方法调用该方法,以便在记录更改时以及记录中发生的更改时提醒我。

它还使用 Axe 内置的电子邮件模板。

static void CompareAndEmail(str emailTemplateName, str nameField, str recipient, Common original, Common modified)
{
    UserInfo    userInfo;
    Map         emailParameterMap = new Map(Types::String, Types::String);
    str         changes;
    int         i, fieldId;    
    DictTable   dictTable = new DictTable(original.TableId);
    DictField   dictField;
;

    for (i=1; i<=dictTable.fieldCnt(); i++)
    {
        fieldId = dictTable.fieldCnt2Id(i);
        dictField = dictTable.fieldObject(fieldId);

        if (dictField.isSystem())
            continue;

        if (original.(fieldId) != modified.(fieldId))
        {
            changes += strfmt("%1: %2 -> %3 \n\r",
                dictField.name(),
                original.(fieldId),
                modified.(fieldId)
            );
        }
    }

    //Send Notification Email
    select Name from UserInfo where userInfo.id == curUserId();
    emailParameterMap.insert("modifiedBy", userInfo.Name);
    emailParameterMap.insert("tableName", dictTable.name());
    emailParameterMap.insert("recordName", original.(dictTable.fieldName2Id(nameField)));
    emailParameterMap.insert("recordChanges", changes);

    SysEmailTable::sendMail(emailTemplateName, "en-us", recipient, emailParameterMap);
}

然后在 .update() 方法中,我只需添加这一行

//Compare and email differences
RecordChangeNotification::CompareAndEmail(
    "RecChange",            //Template to use
    "Name",                 //Name field of the record (MUST BE VALID)
    "[email protected]", //Recipient email
    this_Orig,              //Original record
    this                    //Modified record
);

我想要改进的唯一事情是:

  • 将模板名称和收件人移动到表中,以便于维护,
  • 更好地格式化更改列表,我不知道如何对其进行模板化(请参阅:此处

I have created a new class with a static method that I can easily call from any .update() method to alert me when a record changes, and what changed in the record.

It uses the built in email templates of Ax as well.

static void CompareAndEmail(str emailTemplateName, str nameField, str recipient, Common original, Common modified)
{
    UserInfo    userInfo;
    Map         emailParameterMap = new Map(Types::String, Types::String);
    str         changes;
    int         i, fieldId;    
    DictTable   dictTable = new DictTable(original.TableId);
    DictField   dictField;
;

    for (i=1; i<=dictTable.fieldCnt(); i++)
    {
        fieldId = dictTable.fieldCnt2Id(i);
        dictField = dictTable.fieldObject(fieldId);

        if (dictField.isSystem())
            continue;

        if (original.(fieldId) != modified.(fieldId))
        {
            changes += strfmt("%1: %2 -> %3 \n\r",
                dictField.name(),
                original.(fieldId),
                modified.(fieldId)
            );
        }
    }

    //Send Notification Email
    select Name from UserInfo where userInfo.id == curUserId();
    emailParameterMap.insert("modifiedBy", userInfo.Name);
    emailParameterMap.insert("tableName", dictTable.name());
    emailParameterMap.insert("recordName", original.(dictTable.fieldName2Id(nameField)));
    emailParameterMap.insert("recordChanges", changes);

    SysEmailTable::sendMail(emailTemplateName, "en-us", recipient, emailParameterMap);
}

Then in the .update() method I just add this one line

//Compare and email differences
RecordChangeNotification::CompareAndEmail(
    "RecChange",            //Template to use
    "Name",                 //Name field of the record (MUST BE VALID)
    "[email protected]", //Recipient email
    this_Orig,              //Original record
    this                    //Modified record
);

The only things I want to improve upon are:

  • moving the template name and recipient into a table, for easier maintenance
  • better formatting for the change list, I don't know how to template that (see: here)
做个ˇ局外人 2024-10-11 13:51:12

正如您所观察到的,警报系统并不是为“任何”字段更改而设计的,而仅针对特定字段更改而设计。

无论如何,这是一个虚假请求,因为它会生成许多警报。正确的做法是启用 VendTable 表的数据库日志记录,然后向感兴趣的人发送每日报告(批量)。

这是在管理\设置\数据库日志记录中完成的。 Administration\Reports 中有一份报告。您需要知道桌子编号才能选择桌子。
此解决方案需要“数据库日志记录”许可证密钥。

As you have observed the alert system is not designed for "any" field changes, only specific field changes.

This is a bogus request anyway as it would generate many alarts. The right thing to do is to enable database logging of the VendTable table, then send a daily report (in batch) to those interested.

This is done in Administration\Setup\Database logging. There is a report in Administration\Reports. You will need to know the table number to select the table.
This solution requires a "Database logging" license key.

回忆躺在深渊里 2024-10-11 13:51:12

如果您确实需要此功能,那么您可以创建一个类来发送消息/电子邮件,其中包含旧记录与新记录的足迹。然后只需在表方法“write”/“update”/“save”中添加一些代码,以确保每当编辑 vendtable 时都会运行您的类。
但我必须同意 Jan 的观点。这会产生很多警报。我会花一些精力检查vendtable中所做的修改是否符合业务需求,并禁止非法修改。这包括确保只有合适的人有足够的访问权限。

祝你好运!

If you really need this feature, then you can create a class that sends a message/email with the footprint of the old record vs the new record. Then simply add some code in the table method "write"/"update"/"save" to make sure you class is run whenever vendtable gets edited.
But I have to agree with Jan. This will generate a lot of alerts. I'd spend some energy checking if the modifications done in vendtable are according to the business needs, and prohibit illegal modifications. That includes making sure only the right people have enough access.

Good luck!

无声情话 2024-10-11 13:51:12

我确实同意 Skaue 的建议。你只需写信并上课即可发送售货表更改的邮件。
并在 vendtable 的更新方法上执行此类。

谢谢和问候,
迪帕克·库马尔

I do agree with suggestion of Skaue.you just write and class to send the mail of changes in vend table.
and execute this class on update method of vendtable.

thanks and Regards,
Deepak Kumar

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文