| « Absolute Positioning Inside Relative Positioning | Companion.JS is Firebug for IE » |
Making a global variable in a form
CRM has the OnLoad, OnSave, and OnChange events to add JScript to you so can customize functionality in your forms. I wanted to set a value in the OnLoad event and then access it in the OnSave.
One way to do this would to create an attribute for the entity add it to the form and hide it in some way. The problem I have with this method is when you set that attribute the form is flagged as dirty because a value was changed, and depending on other logic you have in the form this could cause issues.
I looking around the web and then finally made a post on the CRM Newsgroups and got a reply. I found that you can add you own properties to the window property. So in your OnLoad event you could do do this..
window.specialVar = true
and then this in the OnSave event
if(window.specialVar == true){
//run code
}
Hopefully you find this as helpful as I did.
Feedback awaiting moderation
This post has 10 feedbacks awaiting moderation...