• 在CRM2011表单中取消OnSave操作


    好像SDK里没有记这东西,在国外的一博客里找了个贴过来备忘。

     

    转自:http://blogs.infinite-x.net/2011/05/06/crm-2011-canceling-the-save-operation/

     

    ---------------------------------

    There are occasions where you need to abort the saving of a record within CRM. This is accomplished by using JavaScript to instruct CRM to prevent the default action ( which is a save operation ).

    This requires a small piece of JavaScript in the OnSave Event which we will do in the following steps:

    Adding a web resource for the contact form

    In order to utilize JavaScript on our form, we must first attach a JavaScript library web resource to the form:

    Next, we must add an OnSave event to the form:

    Note: The pass execution context as first parameter checkbox is very important to this process. Without it, it will not work.

    Inside the Contact_main_library.js web resource, we’ll add the following function:

    function Form_onsave(executionObj)
    {
        var shouldSave = true;
    
        if (shouldSave)
        {
            alert("Unable to save because of some reason or the other.");
    
            executionObj.getEventArgs().preventDefault();
        }
    }

    Inside the OnSave function, we need to have some type of test to see if we should allow the record to be saved.

    For this demonstration, we simply check the value of a variable called shouldSave. If true, then we display an error message to the user then execute the preventDefault() method which will instruct CRM to cancel the save operation.

    Note: in an actually CRM system you would probably perform checks such as validating data entered by the user is correct and/or appropriate.

    It should also be noted that if you have required fields on the form, CRM will validate those fields first. If any required fields are blank, an warning message will be displayed to the user so they may complete those fields.

    The OnSave event is only fired after all required fields have been populated.

  • 相关阅读:
    POJ3061(尺取法)
    POJ2739(尺取法)
    HDOJ4763(KMP原理理解)
    HDOJ5521(巧妙构建完全图)
    UVALive7261(2015ACM/ICPC北京赛区现场赛A)
    POJ1745动态规划
    POJ1273(最大流入门)
    HDOJ5883(欧拉路)
    HDOJ5437(优先队列)
    HDOJ5875(线段树)
  • 原文地址:https://www.cnblogs.com/bcszz/p/2519593.html
Copyright © 2020-2023  润新知