创建dynamics CRM client-side (六) - form & field notification

form 和 field 的notification在开发当中会经常使用到

 

// Converting functions to Namespace Notation
var Sdk = window.Sdk || {};
(
    function () {
        this.formOnLoad = function (executionContext) {
        };

        this.MailPhoneOnChange = function (executionContext) {
            var formContext = executionContext.getFormContext();
            var phoneNumber = formContext.getAttribute("telephone1").getValue();

            var expression = /^(\()?\d{3}(\))?(-|\s)?\d{3}(-|\s)\d{4}$/;
            if (!expression.test(phoneNumber)) {

          // 显示field 和 form的 notification formContext.getControl(
"telephone1").setNotification("The phone number entered should use correct format","telephonemsg"); formContext.ui.setFormNotification("Info message", "INFO", "formoti1"); } else {
          // 清理field 和 from 的notification formContext.getControl(
"telephone1").clearNotification("telephonemsg"); formContext.ui.clearFormNotification("formoti1"); } }; } ).call(Sdk);

 

我们把代码加载到CRM的account当中,并且测试一下

创建dynamics CRM client-side (六) - form & field notification_第1张图片

 

你可能感兴趣的:(创建dynamics CRM client-side (六) - form & field notification)