Answered by:
Field label formatting [CRM 2011] [Jscript]

Question
-
I've seen this written for 4.0 but how to convert it to Xrm format?
http://social.microsoft.com/Forums/en-US/crm/thread/fb415575-1ad1-41d2-a54a-dcff959adce5
http://social.microsoft.com/forums/en-us/crm/thread/3E093EBE-D7F4-458A-824F-1E6A2F95B0AF
I know ^these will work for CRM 2011 but I'd like it to be in the Xrm (not crmForm) format.
UPDATE:
I loaded the Custom Code Validation Tool (http://www.microsoft.com/en-us/download/details.aspx?id=30151">http://www.microsoft.com/en-us/download/details.aspx?id=30151); according to the tool's Read Me file, getElementById is one of the things that could cause issues
"... the elements that the tool is looking for to assist with validating whether the custom JavaScript and HTML web resources will work with other web browsers such as Chrome, FireFox, and Safari. Some of the elements are simply references to Microsoft technologies, such as ActiveXObject, which are not supported in other browsers. Others are references to the Document Object Model, which may have changed as part of the June 2012 Service Update so customers and partners will want to investigate whether these references are still valid."
Anyone know of a way to do it without using getElementById ?
- Edited by M. Jaxon Tuesday, November 6, 2012 3:33 PM
Wednesday, August 29, 2012 6:01 PM
Answers
-
The thing is that these methods weren't really supported in 4.0 and that has carried forward to 2011. As such, Microsoft didn't build that functionality into the Xrm.Page object model this time around.
Jason Lattimer
- Proposed as answer by JLattimerMVP, Moderator Thursday, August 30, 2012 11:53 AM
- Marked as answer by JLattimerMVP, Moderator Sunday, December 23, 2012 11:45 PM
Thursday, August 30, 2012 2:27 AMModerator -
A supported option could be to use single row html web resources to show the label in whatever style/colour you like and set the data fields to be immediately next to them with their 'show label' property set to do not show. Here's a blog of how to add text blocks so you could adapt it.
Microsoft Certified Technology Specialist (CRM) GAP Consulting Ltd Microsoft Community Contributor Award 2011
- Proposed as answer by Rob BoyersEditor Monday, November 5, 2012 10:19 PM
- Marked as answer by JLattimerMVP, Moderator Sunday, December 23, 2012 11:45 PM
Monday, November 5, 2012 10:19 PMAnswerer
All replies
-
The thing is that these methods weren't really supported in 4.0 and that has carried forward to 2011. As such, Microsoft didn't build that functionality into the Xrm.Page object model this time around.
Jason Lattimer
- Proposed as answer by JLattimerMVP, Moderator Thursday, August 30, 2012 11:53 AM
- Marked as answer by JLattimerMVP, Moderator Sunday, December 23, 2012 11:45 PM
Thursday, August 30, 2012 2:27 AMModerator -
Hi,
If you are looking for the conversion of javascript from 4 to 2011, there are plenty of tools available for this. you can refer to the below given links,
http://crm2011scriptconvert.codeplex.com/
http://bingsoft.wordpress.com/2010/09/09/crm-4-to-crm-2011-javascript-converter-tool/
Thanks,
Thursday, August 30, 2012 4:41 AM -
So, if it I use those 4.0 code snippets, what is the likelihood that cross-browser functionality (when it's rolled out) will cause that to bomb?Thursday, August 30, 2012 4:18 PM
-
It is certainly a possibility - since that code isn't supported it wasn't really addressed in the breaking script changes. You are very likely to see this code break in the next version of CRM after 2011 as crmForm is currently depricated.
Resolve Breaking Script Issues When Upgrading Microsoft Dynamics CRM
Jason Lattimer
Thursday, August 30, 2012 4:28 PMModerator -
Followings are the style that I created for disabled fields, according to the style guide in SDK:
var disabledField = Xrm.Page.getAttribute(field);
document.getElementById(disabledField).style.border = "#c4c8ce 1px solid";
document.getElementById(disabledField).style.color = "#838383";
document.getElementById(disabledField).style.backgroundColor = "transparent";I also tried the following scripts:
document.getElementById(disabledField).style.fontsize = "12px";
document.getElementById(disabledField).style.borderColor = "";I don't think the .style.fontweight works if I remember it right. And hopefully these are good enough for the style/format that you want to achieve.
Thursday, August 30, 2012 4:49 PM -
Hi, Try this from your Sample:
document.getElementById("new_button").style.backgroundColor = 'red';
document.getElementById("new_button").style.Color = 'black';
document.getElementById("new_button").style.borderColor = 'red';
document.getElementById("new_button").style.fontweight = 'bold';
Naren
- Edited by Naren MN Friday, August 31, 2012 11:27 AM
Friday, August 31, 2012 11:26 AM -
I loaded the Custom Code Validation Tool (http://www.microsoft.com/en-us/download/details.aspx?id=30151); according to the tool's Read Me file, getElementById is one of the things that could cause issues.
"... the elements that the tool is looking for to assist with validating whether the custom JavaScript and HTML web resources will work with other web browsers such as Chrome, FireFox, and Safari. Some of the elements are simply references to Microsoft technologies, such as ActiveXObject, which are not supported in other browsers. Others are references to the Document Object Model, which may have changed as part of the June 2012 Service Update so customers and partners will want to investigate whether these references are still valid."
This is me investigating. :)
Friday, August 31, 2012 2:09 PM -
A supported option could be to use single row html web resources to show the label in whatever style/colour you like and set the data fields to be immediately next to them with their 'show label' property set to do not show. Here's a blog of how to add text blocks so you could adapt it.
Microsoft Certified Technology Specialist (CRM) GAP Consulting Ltd Microsoft Community Contributor Award 2011
- Proposed as answer by Rob BoyersEditor Monday, November 5, 2012 10:19 PM
- Marked as answer by JLattimerMVP, Moderator Sunday, December 23, 2012 11:45 PM
Monday, November 5, 2012 10:19 PMAnswerer -
Hello Linhardt,
We can format the fields in by getting those ids from developer tools(f12) and then use javascript coding document.getElementbyId
document.getElementById("name").style.backgroundColor="red";// here name defines the text in the field "name". document.getElementById("name_c").style.backgroundColor="aqua";//here name_c defines the label of field "name" document.getElementById("name_d").style.backgroundColor="yellow";//here name_d defines the border of field "name" document.getElementById("name").style.color="yellow";
(mark as answer and vote as helpful) if my reply works for u.
Thanks,
SASANK K
Tuesday, November 6, 2012 4:24 AM