{Dynamics 365 Enhancements} Add Notification Recommendations to your Entity forms using script

Sending
User Review
0 (0 votes)

This blog is part of the series which I will use to cover all interesting enhancements coming in Dynamics 365.

Scenario: On Account form, if user fills in the Telephone field – suggest a recommendation to set Contact preference by Phone field. If user selects yes, set Contact by Phone option to allow.

Scenario by Graphics:

· On change of phone field, CRM shows a recommendation tooltip:

clip_image001

· When you click the information icon, CRM gives you a recommendation:

clip_image002

· If you pick Apply, CRM will do the updating to the field as required:

clip_image003

Great isn’t it?

Here is the link describing the new Client side scripting function: https://msdn.microsoft.com/en-us/library/gg334266.aspx#BKMK_addnotification

And here is the script for this one (Register it on change event of Phone field):

function addPhonePreferenceNotification() {

var myControl = Xrm.Page.getControl(‘telephone1’);

var telephone= Xrm.Page.data.entity.attributes.get(‘telephone1’);

var phonePreference = Xrm.Page.data.entity.attributes.get(‘donotphone’).getValue();

if (telephone.getValue() != null) {

var actionCollection = {

message: ‘Set the Contact Preference for Phone to Allow?’,

actions: null

};

actionCollection.actions = [function () {

Xrm.Page.data.entity.attributes.get(‘donotphone’).setValue(false);

myControl.clearNotification(‘my_unique_id’);

}];

myControl.addNotification({

messages: [‘Set Phone Preference’],

notificationLevel: ‘RECOMMENDATION’,

uniqueId: ‘my_unique_id’,

actions: [actionCollection]

});

}

else

console.log(“Notification not set”);

}// JavaScript source code

Hope it helps and Happy CRMing!



Check this out

ABOUT THE AUTHOR:

clip_image001

Twitter: https://twitter.com/msdynamicsblog
LinkedIn: https://www.linkedin.com/in/deepesh-somani-00296932

Google Play Store:

https://play.google.com/store/apps/details?id=com.dynamicsofdynamicscrm.msdynamicsblog&hl=en