如果特定字段不为空(在更改时),我需要在实体中显示自定义警告消息。
我在一个不同的公司全球JS文件中写了显示消息的代码:
addNotification: function (message) { //Adds a warning message on the top of the entity Form
var notificationHTML = '<DIV class="Notification"><TABLE cellSpacing="0" cellPadding="0"><TBODY><TR><TD vAlign="top"><IMG class="ms-crm-Lookup-Item" alt="" src="/_imgs/error/notif_icn_crit16.png" /></TD><TD><SPAN>' + message + '</SPAN></TD></TR></TBODY></TABLE></DIV>';
var notificationsArea = document.getElementById('Notifications');
if (notificationsArea == null) return;
notificationsArea.innerHTML += notificationHTML;
notificationsArea.style.display = 'block';
},
在我的实体JS文件中我写了这个:
function checkIfAssignToIsEmpty() {
var AssignTo = Xrm.Page.getAttribute('el_assign_to').getValue();
if (AssignTo != null)
newNotification();
}
function newNotification() {
var assignToVal = Xrm.Page.getAttribute("el_assign_to").getValue();
var newNotification = GlobalFunction.addNotification('assiignToVal + The Task will assign to');
}
在我的字段中选择值后,我收到错误消息
对象不支持属性或方法&#39; addNotification&#39;
你能帮忙吗?
答案 0 :(得分:1)
您可以使用支持的通知方法
Xrm.Page.ui.setFormNotification(message, level, uniqueId);
和
Xrm.Page.ui.clearFormNotification(uniqueId);
还有控件通知。你可以在这里找到几个例子: http://garethtuckercrm.com/2013/10/17/crm-2013-new-features-javascript-notifications/