Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

upgrade crm 4 to crm 2011 RU 17

Posted on by Microsoft Employee

hey all, 

we just upgraded our crm to crm 2011 RU17, when we finish all we will upgrade -2013/15/16..

I have that function, that fails on the bold lines, or everywhere it written "Node"

who can help me to review my code?

please

function ShowHideFields(prmXmlElement)//run on the xml and show the fields accordingly
{
debugger;
var mainTabSectionArea = crmForm.all.tab0.childNodes[0].childNodes[0]; //get the main tab 
if (mainTabSectionArea.childNodes !=0)
mainTabSectionArea.childNodes[0].removeNode(true); //remove blank tr on top
//var mainTabSectionArea = Xrm.Page.getAttribute("tab0.childNodes[0].childNodes[0]");
//mainTabSectionArea.childNodes[0].removeNode(true);
if (isNewForm)//if form is new then insert value into the subject field
{

switch (prmXmlElement.getAttribute("name"))//do a switch on the group name
{
case "RegularServiceCenter": //regular service center
//if (oReturnValue.ServiceType == 1)//if Regular
InsertSubjectValue("Regular");
//else//else smart
// InsertSubjectValue("Smart");
break;
case "OutsourceServiceCenter": //outsource
InsertSubjectValue("Outsource");
break;
case "Lab": //Lab
InsertSubjectValue("Lab");
break;
case "Installation": //Installation
InsertSubjectValue("Installation");
break;
}
}
objSections = prmXmlElement.getElementsByTagName("Section");
for (var i = 0; i < objSections.length; i++) {
var tempObjSection = objSections[i]; //get the current section
var SectionID = tempObjSection.getAttribute("ID"); //get the section name
var newSection = document.getElementById(SectionID).parentNode.parentNode; //get the HTML code of the section
mainTabSectionArea.appendChild(newSection);
var SectionCols = document.getElementById(SectionID).childNodes[0];
//add the cols to the colgroup
var SectionCols = document.getElementById(SectionID).childNodes[0];
var newSectionCols = SectionCols.cloneNode(false); // no child nodes;
SectionCols.parentNode.replaceChild(newSectionCols, SectionCols);
var cols1 = document.createElement("col");
cols1.setAttribute('width', 115);
var cols2 = document.createElement("col");
var cols3 = document.createElement("col");
cols3.setAttribute('width', 135);
cols3.setAttribute('class', 'FormSection_WriteColumnHeaders_col');
var cols4 = document.createElement("col");
newSectionCols.appendChild(cols1);
newSectionCols.appendChild(cols2);
newSectionCols.appendChild(cols3);
newSectionCols.appendChild(cols4);
var SectionWorkspace = document.getElementById(SectionID).childNodes[1];
SectionWorkspace.childNodes[0].childNodes[0].setAttribute('colSpan', 4);
var objFields = tempObjSection.getElementsByTagName("Field");
var countFields = 0; //count number of fields in a row
var new_row = null; //a new row object
var last_SchemaName = ""; //the last schema name
for (var j = 0; j < objFields.length; j++) {
var tempObjField = objFields[j]; //get the current field
var FieldSchemaName = tempObjField.getAttribute("SchemaName"); //get the schema name of the field
var FieldLabel = tempObjField.getAttribute("Label"); //get the label of the field
var Fieldcolspan = tempObjField.getAttribute("colspan"); //get the colspan of the field
var FieldAllRow = tempObjField.getAttribute("allRow"); //get the colspan of the field

var objField_c = document.getElementById(FieldSchemaName + "_c"); //get the lable td
try {
var strInnerValue = "";
if (objField_c != null)
strInnerValue = objField_c.childNodes[0].innerHTML; //get inner html of lable
}
catch (error) {
alert(FieldLabel);
}
if (strInnerValue.indexOf('img') >= 0)
objField_c.childNodes[0].innerHTML = FieldLabel + "<img alt=\"נדרש\" src=\"/_imgs/frm_required.gif\">";
else {
if (objField_c != null)//<<<---Fix from 03.04.14
objField_c.childNodes[0].innerHTML = FieldLabel;
}
var isTextArea = tempObjField.getAttribute("isTextArea"); //is this field TextArea?
if (countFields == 0)//if first field in row
{
new_row = document.createElement("tr"); //create new row
new_row.setAttribute("vAlign", "top");
}

if (countFields == 1) {
objField_c.style.paddingRight = "20px";
}
var new_td_c = document.createElement("td"); //create new row
var new_td_d = document.createElement("td"); //create new row
new_td_c.innerHTML = "";
new_td_d.innerHTML = "";
new_td_c.setAttribute("id", "new_td" + i + j + "_c");
new_td_d.setAttribute("id", "new_td" + i + j + "_d");

if (Fieldcolspan == 2)//if the colspan of the field is 2 then
{
countFields = 2; //raise by 2
new_td_d.setAttribute("colSpan", 2);
}
else
countFields = countFields + 1; //raise by 1

new_row.appendChild(new_td_c);
new_row.appendChild(new_td_d);

if (j == objFields.length - 1)//if last field
countFields = 2;

if (countFields == 2)//if no more fields in row
{
SectionWorkspace.appendChild(new_row); //add row to the form
countFields = 0;
if (last_SchemaName != "") {
SwapF("new_td" + i + (j - 1), last_SchemaName);
}
SwapF("new_td" + i + j, FieldSchemaName);
last_SchemaName = "";
}
else {
last_SchemaName = FieldSchemaName;
}

if (isTextArea == "true") {
var textareaRow = document.createElement("tr");
textareaRow.setAttribute("valign", "top");
textareaRow.setAttribute("height", 25);
var textareaRow2 = textareaRow.cloneNode(true);
var textareaRow3 = textareaRow.cloneNode(true);
SectionWorkspace.appendChild(textareaRow);
SectionWorkspace.appendChild(textareaRow2);
SectionWorkspace.appendChild(textareaRow3);
}

}
}
}

 

*This post is locked for comments

  • Suggested answer
    Wayne Walton Profile Picture
    Wayne Walton 13,726 on at
    RE: upgrade crm 4 to crm 2011 RU 17

    Along with what Guido said, you really should run the Custom Code Validation Tool to verify all the code that definitely won't work as you migrate: www.microsoft.com/.../details.aspx

    Lastly, if you are planning to go all the way to 2016, just abandon all your UI code.  CRM 2016 uses a new API completely called WebAPI, and nothing from older systems will work going forward.  Much better to use what is fully supported in 2016 than the older APIs.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans