Thursday, June 9, 2011

CRM 2011 – Using Javascript to identifying Form context for the record

There are often situations when as a developer you need to check the form whether form is open for create new record or is open for update record. This can be very useful to check whether form is open for create which case need to assign some default values to the some of the controls on the form.JavaScript code is listed in List 1 here you can see that form can be open for six different context including the create and update context.

List 1
In the code above you can see that Xrm.Page.ui.getFormType() is used to get the context of the form. It will return the value of type number which will then check as I have do in switch statement to do appropriate action depending on the context in which form has opened.

All and any comments / bugs / suggestions are welcomed !

3 comments:

Vee Eee Technologies said...

Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write ups thanks once again.

let it snow said...

very nice thanks for sharing

hey friend see snow on google
Type “Let It Snow” on @Google If you click and drag you can wipe the snow away. It is great. source: http://le-titsnow.blogspot.com

Anonymous said...

From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the good work.
source: www.wbupdates.com