Topics

Knowledge Creation Laboratory by CRM(xRM)

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.
0903-001
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.
0903-002
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.
0903-003
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
Kengo Harada

Liberal arts programmer (.NET Framework, Java).
I started this program at the age of 25 and worked as hard as I could (I praise myself because no one else praises me).
Before I knew it, I was the manager of the product development department...
Our companyDynamics CRM TrainingI also work as a lecturer.
There are business divisions and job titles, but the title that best suits me is "handyman within the business division."
Arcus Japan Co., Ltd. CRM Products
CRM product inquiries
TEL +06-6195-7501-XNUMX
CONTACT

Articles in the same category