CRM 2011 – Using Javascript to identifying if a form is in Create or Update Contect

Here is a quick tip to tell if a form is being created or updated in Javascript, this can be very useful for form load events and creating code which needs to be run when a form is being created, like setting the values of variables when a form is created.

var  formType= Xrm.Page.ui.getFormType();
getFormType() function returns a number
If the return value is 1 –  Form context is Create
If the return value is 2 –  Form context is Update
About these ads

4 thoughts on “CRM 2011 – Using Javascript to identifying if a form is in Create or Update Contect

  1. Goodfella February 23, 2012 / 7:58 am

    Hi,
    and what about delete state ? How can I start jscript if record is being deleted ?

  2. Harold May 29, 2013 / 4:41 pm

    Hmmm, it’s work fine but it don’t respond to my problems.

    Do you know how to identify when you open an email entity to write and send one or just to read it.

    Because when you use formtype = 1, it’s great for new email but not for replies…
    Replies seem be formtype = 2

    thanks

    PS: I think that for email you should verify if the status is open or close when you want know if it’s new email or not.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s