CRM 2011/2013 – use the debugger console to enabled/disable controls on a form

I was trying to fix a small bug but I was getting bogged down with the business logic (which I didn’t need/want to change) on the form.

The problem was there was lots of business logic which kept disabling the fields I wanted to change.

I tried briefly to understand the business logic but it was complex and detailed and I wasn’t really interested in understanding the form logic and/or briefly amending the JavaScript onload.  All I needed to do was to enable an optionset on the form, which would enable a ribbon button.

So it’s time for a bit of off the cuff hacking

I loaded the form

Press F12 to bring up the debugger window

You can use the console to manipulate the fields and enable/disable certain fields.

You have access to the CRM JavasScript objects

So I used the Xrm.Page, selected the control (not the field attribute) and did a setDisabled(false); which enables the control.
Xrm.Page.getControl(customerid”).setDisabled(false);
This didn’t enable the ribbon button because although the JavaScript function which is used by the ribbon button (e.g. the enable rule for the Ribbon button) the ribbon hadn’t been refreshed.

So I used the console to do a Ribbon Refresh

Xrm.Page.ui.refreshRibbon();

Fantastic, now my field was enabled and the ribbon button was enabled and ready to be pressed.

 

Other uses for F12 JavaScript debugger is to get the guid of the record, which I did on this blog post

 

Browser bookmark

An alternative to bringing up the F12 debugger is to create a bookmark, this will enable you to pass javascript into a form before loading it.

The blog post below created a God Button, which enables all fields

http://www.magnetismsolutions.com/blog/paulnieuwelaar/2014/07/29/activate-god-mode-in-crm-2013—don-t-let-your-users-see-this

 

This blog post will talk you through the logic and is the first part in a series of blog posts on the subject

http://blog.sonomapartners.com/2014/01/crm-2013-javascript-bookmark-series-part-1.html

 

Advertisement