-
Note regarding crmForm.FormType
I was writing a bit of Javascript yesterday when I noticed something interesting related to the value of the crmForm.FormType property.
The crmForm has a property called FormType, which allows you to distinguish between the different types of forms you may encounter as a user creates or edits a CRM Entity.
When a user clicks the New button to create a new Entity, the FormType is set to 1, for Create Form. If the user clicks the Save button ( not Save and Close ), CRM will save the record, as expected. From that point forward, CRM considers the user's operation to be an Edit of existing data, rather than the entry of New data.
Subsequently, the FormType is changed to reflect that fact: After the Save button is clicked, the FormType is changed to 2, for Update Form.
I've only had to track the FormType in very rare instances but this is something that you need to keep in mind if you ever need to differentiate between Create and Update, and if you ever expect the user to save their data, but keep the form open to continue editing.
References:
http://blogs.infinite-x.net/2007/03/19/verifying-form-context-before-invoking-javascript-code/
Customization, Dynamics CRM 3,341 views4 responses to “Note regarding crmForm.FormType”
-
Andy Milner September 11th, 2007 at 05:01
Hi Mitch
Something else to consider when using code on the onload event and form types is when a user selects the quick create option. In this case the form is different to the standard one (less fields). Should your code reference one of the fields from the standard form but not the quick create form then you can run into problems and generate error messages for the user (not nice).
To resolve this you can check if the FormType is set to 5 (quick create) and code appropriatley.
Andy.
-
Andy,
That is an excellent point. I have an article discribing just such a situation – http://blogs.infinite-x.net/2007/03/19/verifying-form-context-before-invoking-javascript-code/
But I totally forgot to reference it in the article.
Thanks for the reminder.
Mitch
-
A.Garcia August 28th, 2008 at 22:12
Hi Mitch,
Have you ever tried to force the change of a form type in an OnLoad event? For example, if a certain set of fields meet pre-defined criteria, then set the type from 2 to 3 or 2 to 4 thereby making a temporary override of the user's security rights on just that form (not the entity at large)?
-
Garcia,
That's really not something that would work the way you think it would. Nor would it be something I'd try.
Mitch
Leave a reply
-



