CRM JavaScript - SendAppNotification

问题描述 投票:0回答:1

我们正在尝试模拟以下 Microsoft 文章中描述的 CRM Toast 通知 JavaScript 功能...

https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/send-in-app-notifications?tabs=clientapi

使用本文中的第一个示例,通知已成功发送给用户:

var SendAppNotificationRequest = new Example.SendAppNotificationRequest(
    title = "Welcome",
    recipient = "/systemusers(8d585985-e1f4-ed11-8818-0022483d019b)",
    body = "Welcome to the world of app notifications!",
    priority = 200000000,
    iconType = 100000000,
    toastType = 200000000,
);

但是,当我们尝试下面的第二个示例(其中包含 overrideContent 元素)时,我们会收到错误:

var SendAppNotificationRequest = new Example.SendAppNotificationRequest(title = "SLA critical",
    recipient = "/systemusers(8d585985-e1f4-ed11-8818-0022483d019b)",
    body = "Record assigned to you is critically past SLA.",
    iconType = 100000003,
    toastType = 200000000,
    overrideContent = {
        "@odata.type": "#Microsoft.Dynamics.CRM.expando",
        "title": "**SLA critical**",
        "body": "Case record [Complete overhaul required (sample)](?pagetype=entityrecord&etn=incident&id=0a9f62a8-90df-e311-9565-a45d36fc5fe8) assigned is critically past SLA and has been escalated to your manager."
    }
);

这是我们在尝试执行第二个示例时收到的错误:

"message": "Error identified in Payload provided by the user for Entity :'', 
For more information on this error please follow this help link https://go.microsoft.com/fwlink/?linkid=2195293  
---->  InnerException : System.ArgumentException: Stream was not readable.

有人之前见过这个或者知道为什么第二个示例返回此错误吗?

更新: 查看“网络”选项卡中的 JSON 有效负载(感谢 @Andrew Butenko),我看到了以下内容...

{
"Title":"SLA critical",
"Recipient":"/systemusers(8d585985-e1f4-ed11-8818-0022483d019b)",
"Body":"Record assigned to you is critically past SLA.",
"Priority":100000003,
"IconType":200000000,
"ToastType":[object Object],
"Expiry":null,
"OverrideContent":null,
"Actions":null
}

IconType、ToastType、OverrideContent 元素似乎分配不正确。本质上,它们已上移 1 个元素,使 OverrideElement 为 NULL。

我将变量声明/赋值更改为以下有效...

var SendAppNotificationRequest = new alya_shared.SendAppNotificationRequest();
sendAppNotificationRequest.Title = "SLA critical",
sendAppNotificationRequest.Recipient = "/systemusers(8d585985-e1f4-ed11-8818-0022483d019b)",
sendAppNotificationRequest.Body = "Record assigned to you is critically past SLA.",
sendAppNotificationRequest.IconType = 100000003;
sendAppNotificationRequest.ToastType = 200000000;
sendAppNotificationRequest.OverrideContent = {
"@odata.type": "#Microsoft.Dynamics.CRM.expando",
"title": "**SLA critical**",
"body": "Case record [Complete overhaul required (sample)](?pagetype=entityrecord&etn=incident&id=0a9f62a8-90df-e311-9565-a45d36fc5fe8) assigned is critically past SLA and has been escalated to your manager."
};
javascript dynamics-crm microsoft-dynamics crm
1个回答
0
投票

我建议检查网络流量并检查它是否提供更多信息。以下步骤描述了您可以执行哪些操作来查看网络流量:

谷歌浏览器:

  • 打开开发者工具(菜单 > 更多工具 > 开发者工具或 Ctrl + Shift + I 或 F12)
  • 选择网络选项卡。
  • 执行导致行为/问题的步骤

火狐(41+):

  • 转到菜单 > Web 开发人员 > 网络
  • 重新加载您想要获取日志的页面
  • 执行导致行为/问题的步骤

Internet Explorer 和 Edge:

  • 打开开发者工具(F12)
  • 转到网络选项卡并单击绿色箭头启动该工具
  • 列出项目

执行导致行为/问题的步骤

© www.soinside.com 2019 - 2024. All rights reserved.