Hello community,
I am currently trying to implement the new functionality of the in-appnotification. Microsoft published this topic in September of the last year:
Send in-app notifications within model-driven apps (preview)
Based on this documentation and description, I was able to activate the function on my system without any problems.
It is now my goal to trigger such a notification on my system using a plugin and to display it to a system user. For a first simple try, I wrote this method:
void CreateNotification(PluginContext context, Guid userId, String entitiyName) { var notification = new Entity("appnotification"); notification["title"] = "This is the title."; notification["body"] = $"This is the body of the notification."; // notification["icontype"] = 100000000; // prevents notification from being created // notification["toasttype"] = 200000000; // prevents notification from being created // notification["ttlinseconds"] = 10; // prevents notification from being created notification["ownerid"] = new EntityReference("systemuser", context.InitiatingUserId); context.OrganizationService.Create(notification); }
As long as the lines for setting icontype, toasttype and ttlinseconds are commented out, the test notification is displayed to the system user. However, the user must actively click the bell-icon at the top right of the ribbon to see the notification. If the fields are set, the action is not carried out and no notification is created. I could do without setting the icon. But it is very important for the application that the toast type and the time are set in order to display the notification to the user for a short time.
I also tried to set those explicitly stating that the values are Int32:
notification["icontype"] = Convert.ToInt32(100000000); notification["toasttype"] = Convert.ToInt32(200000000); notification["ttlinseconds"] = Convert.ToInt32(10);
Unfortunately without success.
If someone could already successfully set such a notification, or had any idea what could cause this problem, I would be very grateful for any advice!