Declaration: -
This article is only for learning purpose. Use these articles only in
development environment. I am not prompting this to use in any production
environment.
This article only for CRM developer. I am not prompting this
to use by any end customer.
Problem: - As a
developer some type we do not remember each, and every function given by XRM
library or some time syntax not correct. We can find many options to add XRM intellisense
in for visual studio. XRM Intellisense
But some time if we do not have access to visual studio? And
these intellisense are not updated automatically when our Dynamics CRM versions
are update and we are not aware about new function added or removed by Microsoft.
Or If there is any beginner who not aware of function present
in XRM Javascript library.
Solution: -
As we aware Chrome give better performance for Dynamics 365
as compared to Internet Explore.
Here, I am going to introduce one another great feature of
Chrome that is “Console”. We mostly use console.log(“our message”) in Javascript
to write information or error that can help us later.
But we can also use Chrome Console option to use XRM intellisense.
Steps: -
- Open your development Dynamics CRM environment. Navigate to any CRM record. I am taking case record for example.
2.Go
to form property and add a function onSave event. That function need to have debugger; so our Chrome Debugger tools
can work.
3. I am using a sample function which only contain debugger statement.
function test()
{
debugger;
}
If debugger is not written in our code, we will receive real
time or property will return null.
4. Publish your changes and refresh your record page (Press
Ctrl+ r)
Now we are ready to use Chrome Console.
5. Press F12 or Ctrl+ Shift + I or using Chrome tools option to
open developer tool.
6. Now Click on save button this transfer control to Developer
Tools.
7. Go to “Console” tab of developer tools.
When you start typing X it intellisense will start working. As in below image I have entered Xrm.Page.ge
It starts showing all available functions.
Even we can check how our code will behave same as written
in Javascript file.
In my example I am using Xrm.Page.getAttribute('description')
function. When you click on _proto_: link it will start showing all the method
available to “getAttribute” method for field type “Single line text”
You will also see some additional method for “Lookup” attribute
which is normally not shown in any intellisense.
Even when you use make any change it will show real time. I am going to change attribute required level using this.
Without My code
After using code: -
Xrm.Page.getAttribute('description').getRequiredLevel('required')
We have changed form behavior without writing any code in
our Javascript file. So, we can use intellisense and real time code impacts.
This Console can also override Dynamics 365 customization. But
this will not breach field level security field, which is great.
Example: - There
is one “Read-Only” field on form which cannot be update by user. But with this
cheat code allow you to update “Read-Only” field also.
Use this feature only for development and testing.