Manipulating Dynamics CRM Xrm.Page Header Fields
Good evening everyone!
This is Harada, who was hit with an incredible stomach ache a few days ago and couldn't leave the toilet lol
Everyone, please be careful not to drink too much cold food.(But it doesn't really matter! lol)
Speaking of trivial matters, my favorite food isGrilled meat.Grilled meat.Grilled meat.(I wrote it three times in bold because it's important. It's not a typo lol)
Now, leaving my pointless story aside, let's get to the main topic. This time, I'd like to use Xrm.Page to manipulate the fields placed in the header. If you're thinking, "What? It's the same as before!", you're right. There's not much difference lol.
However, you may encounter issues such as not being able to set an OnChange event for a field placed in the header, or an error occurring when trying to get a value using Xrm.Page because the field cannot be found. So, I'm going to tell you how to solve the above problem here!
Header fields?
First, let me explain the part I wrote "cannot do" at the beginning.
Lead(They were called potential customers until Dynamics CRM 2013)This is explained in the entity.
Can't set OnChange on header fields?
Open the form editor and open the properties of the Rating field.

Look, there's no "Events" tab. The lovely OnChange event is missing...(I wonder if there are people out there who are thinking, "That's a problem..."?)
Can't get header fields with Xrm.Page?
Next, let me show you how you can't get fields using Xrm.Page.
Xrm.Utility.alertDialog(Xrm.Page.getControl("leadqualitycode"), function() { } );
Create a web resource and set it in the form's OnLoad event.

You can't get it, right? By the way, Xrm.Page.getAttribute works.(This is a problem... I want to hide it...)
You can do it with a little magic!
So, I'll explain how to achieve this.
You can get it just by adding a little "magic spell" to the field name.
Xrm.Utility.alertDialog(Xrm.Page.getControl("header_leadqualitycode"), function() { } );
I tried rewriting it as follows.

Well, what a thing to say.(I tried to create a before and after look like Dai○zo!!○ lol)
You have gained control, haven't you?! (LOL) Now you can toggle the visibility.
The OnChange event can be set by using Xrm.Page.getAttribute("fieldname").addOnChange.
Next episode preview???
I have introduced various client-side scripts using Xrm.Page, but I hope you understand them. I think it's safe to assume that you can achieve almost anything you want.
I'm already thinking about what to do next lol. If you have any questions, please leave a comment.(Have they finally run out of ideas? LOL)
I'm wondering whether to use a Web API or an SDK! (The devil is whispering to me, "Just copy it from some other site!" lol)
Maybe I'll make it a Web API! Maybe... just maybe? lol Stay tuned to see what the next post will be about!!!
*The content of this article is for personal reference only. Please use the content of this article at your own discretion.
Person who wrote this article
Articles in the same category
-
One with One Marketing: Practical Application — Theory, Day by Day […] -
How to explain CRM 4.0 at a management meeting — "Another buzzword..." -
Checklist for Graduating from Excel Management — "I think I've reached my limit..." -
The limitations of continuing to manage sales using Excel templates — "It's convenient, but..." -
[EMOROCO CRM Lite Feature Introduction] Part 2: Enti[…] -
Reasons why you might not notice customers leaving — "I never thought so..." [...]
