Global functions in MS CRM Form.
The way CRM adds the javascript to the page, any function defined in the onload event will only have a local scope and can only be called from within the same onload event. However, if you put the function on the window object, then it should have global scope:
window.MyCustomFunction = function() { ... }
And then you should be able to call the function from an onchange event.
Ex:
// function name = MyCustomFunction
window.MyCustomFunction = function() {
alert("My Global Level Function");
}
1. Go to MS CRM -> Customisations -> Customise Entity -> Choose Entity -> Form and View
2. Go to OnLoad()
3. Put the above fucntion onLoad() // Should be first statment.
4. Go to OnSave()
5. Call this function, MyCustomFunction();
6. When you try to save the entity record this fucntion will get executed.
Hope you enjoy this tip.
No comments:
Post a Comment