I am receiving the following error message regarding some java code that was written.
This is the error message:
The JavaScript web resources in your system contain a reference to the Microsoft Dynamics CRM 4.0 (2007) Web service endpoint. The 2007 endpoints are not supported in this release. For information about how to upgrade custom code, refer to the Microsoft Dynamics CRM 2011 SDK topic "Upgrade Your Code from Microsoft Dynamics CRM 4.0 to Microsoft Dynamics CRM".
We have detected the presence of legacy component(s) during upgrade, these components are not supported in Dynamics CRM 2015. Please refer to upgrade log file C:\Users\Administrator.PRMECH\AppData\Roaming\Microsoft\MSCRM\Logs\LegacyFeatureCheck.xml for more information.
Here is the java code:
function Form_onload()
{
if(crmForm.FormType ==1)
{
crmForm.all.new_maintsalesrep.Disabled = true;
crmForm.all.new_projectsalesrep.Disabled = true;
crmForm.all.new_areaservicemanager.Disabled = true;
crmForm.all.ws_primarytechnicianid.Disabled = true;
crmForm.all.new_customerservicerep.Disabled = true;
}
crmForm.all.ws_opportunitynumber.Disabled = true;
crmForm.all.ws_grossmarginpercentage.Disabled = true;
crmForm.all.customerid_c.title = "Company receiving the Proposal NOT THE PERSON.";
crmForm.all.ws_primecontractor_c.title = " Customer receiving the bill.";
crmForm.all.new_primarylocation_c.title = "Building where the work is being performed.";
crmForm.all.ws_bidtype_c.title = "Service is for CSRs only.";
switch (crmForm.all.ws_bidtype.SelectedText) {
//switch (Xrm.Page.getAttribute("ws_bidtype").getSelectedOption()) {
case "Service":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
break;
case "Project":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
break;
case "Project - Change":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
break;
case "Maintenance - Renewal":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
break;
case "Maintenance":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
break;
case "Maintenance - Addition":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
break;
case "Maintenance - Deduction":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
break;
case "Maintenance - Reprice":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "hidden";
break;
case "Controls":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
break;
case "Controls - Change":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
break;
case "AC Tuneup":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
break;
case "Budget":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
break;
case "Maintenance - Cancellation":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
break;
}
}
function Form_onsave()
{/********************************CRM Toolkit************************/
/**
* MSCRM4 Web Service Toolkit for JavaScript v2.1
* @author Daniel Cai, http://danielcai.blogspot.com/
* @license Microsoft Public License (Ms-PL), www.opensource.org/.../ms-pl.html
* Date: July 4, 2010
*/
CrmServiceToolkit = function () { var _dateTimeExpr = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})[\.\d{3}]?([-+]\d{2}):(\d{2})$/, _numberExpr = /^[-+]?\d*\.?\d*$/, _integerExpr = /^[0-9]\d*$/; var _doRequest = function (soapBody, requestType, async, internalCallback) { async = async || false; var soapXml = ["<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>", GenerateAuthenticationHeader(), "<soap:Body>", "<", requestType, " xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>", soapBody, "</", requestType, ">", "</soap:Body>", "</soap:Envelope>"].join(""); var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); xmlhttp.open("POST", "/MSCRMServices/2007/crmservice.asmx", async); xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xmlhttp.setRequestHeader("SOAPAction", "schemas.microsoft.com/.../WebServices" + requestType); xmlhttp.send(soapXml); if (async) { xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { internalCallback(_processResponse(xmlhttp.responseXML, xmlhttp.responseText)) } else { throw new Error("HTTP-Requests ERROR: " + xmlhttp.statusText) } } } } else { var result = _processResponse(xmlhttp.responseXML); return !!internalCallback ? internalCallback(result) : result } }; var _processResponse = function (responseXml, responseText) { if (responseXml === null || responseXml.xml === null || responseXml.xml === "") { if (responseText !== null && responseText !== "") { throw new Error(responseText) } else { throw new Error("No response received from the server. ") } } var error = responseXml.selectSingleNode("//error"); var faultString = responseXml.selectSingleNode("//faultstring"); if (error !== null || faultString !== null) { throw new Error(error !== null ? responseXml.selectSingleNode("//description").nodeTypedValue : faultString.text) } var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = false; xmlDoc.loadXML(responseXml.xml); return xmlDoc }; var _fetch = function (fetchXml, callback) { var msgBody = "<fetchXml>" + _HtmlEncode(fetchXml) + "</fetchXml>"; var async = !!callback; return _doRequest(msgBody, "Fetch", !!callback, function (resultXml) { var fetchResult = resultXml.selectSingleNode("//FetchResult"); resultXml.loadXML(fetchResult.childNodes[0].nodeValue); var resultNodes = resultXml.selectNodes("/resultset/result"); var results = []; for (var i = 0; i < resultNodes.length; i++) { var entity = new _businessEntity(); entity.deserialize(resultNodes[i]); results[i] = entity } if (!async) { return results } else { callback(results) } }) }; var _retrieve = function (entityName, id, columnSet, callback) { var attributes = ""; if (columnSet !== undefined) { for (var i = 0; i < columnSet.length; i++) { attributes += "<q1:Attribute>" + columnSet[i] + "</q1:Attribute>" } } var msgBody = ["<entityName>", entityName, "</entityName>", "<id>", id, "</id>", "<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>", "<q1:Attributes>", attributes, "</q1:Attributes>", "</columnSet>"].join(""); var async = !!callback; return _doRequest(msgBody, "Retrieve", !!callback, function (resultXml) { var retrieveResult = resultXml.selectSingleNode("//RetrieveResult"); var entity = new _businessEntity(); entity.deserialize(retrieveResult); if (!async) { return entity } else { callback(entity) } }) }; var _retrieveMultiple = function (query, callback) { var msgBody = ["<Request xsi:type='RetrieveMultipleRequest' ReturnDynamicEntities='false'>", "<Query xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:QueryExpression'>", query, "</Query>", "</Request>"].join(""); var async = !!callback; return _doRequest(msgBody, "Execute", async, function (resultXml) { var resultNodes = resultXml.selectNodes("//BusinessEntityCollection/BusinessEntities/BusinessEntity"); var results = []; for (var i = 0; i < resultNodes.length; i++) { var entity = new _businessEntity(); entity.deserialize(resultNodes[i]); results[i] = entity } if (!async) { return results } else { callback(results) } }) }; var _execute = function (request, callback) { var async = !!callback; return _doRequest(request, "Execute", async, function (resultXml) { if (!async) { return resultXml } else { callback(resultXml) } }) }; var _create = function (businessEntity, callback) { var request = businessEntity.serialize(); var async = !!callback; return _doRequest(request, "Create", async, function (resultXml) { var response = resultXml.selectSingleNode("//CreateResponse/CreateResult"); var result = CrmEncodeDecode.CrmXmlDecode(response.text); if (!async) { return result } else { callback(result) } }) }; var _update = function (businessEntity, callback) { var request = businessEntity.serialize(); var async = !!callback; return _doRequest(request, "Update", async, function (resultXml) { var response = resultXml.selectSingleNode("//UpdateResponse"); var result = CrmEncodeDecode.CrmXmlDecode(response.text); if (!async) { return result } else { callback(result) } }) }; var _delete = function (entityName, id, callback) { var request = ["<entityName>", entityName, "</entityName>", "<id>", id, "</id>"].join(""); var async = !!callback; return _doRequest(request, "Delete", async, function (resultXml) { var response = resultXml.selectSingleNode("//DeleteResponse"); var result = CrmEncodeDecode.CrmXmlDecode(response.text); if (!async) { return result } else { callback(result) } }) }; var _joinArray = function (prefix, array, suffix) { var output = []; for (var i = 0; i < array.length; i++) { if (array[i] != "" && array[i] != undefined) { output.push(prefix, array[i], suffix) } } return output.join("") }; var _joinConditionPair = function (attributes, values) { var output = []; for (var i = 0; i < attributes.length; i++) { if (attributes[i] != "") { output.push("<condition attribute='", attributes[i], "' operator='eq' value='", values[i], "' />") } } return output.join("") }; var _isArray = function (input) { return input.constructor.toString().indexOf("Array") != -1 }; var _queryByAttribute = function (queryOptions, callback) { var entityName = queryOptions.entityName; var attributes = queryOptions.attributes; var values = queryOptions.values; var columnSet = queryOptions.columnSet; var orderby = queryOptions.orderby || ""; attributes = _isArray(attributes) ? attributes : [attributes]; values = _isArray(values) ? values : [values]; orderby = (!!orderby && _isArray(orderby)) ? orderby : [orderby]; columnSet = (!!columnSet && _isArray(columnSet)) ? columnSet : [columnSet]; for (var i = 0; i < values.length; i++) { values[i] = _encodeValue(values[i]) } var xml = ["<fetch mapping='logical'>", " <entity name='", entityName, "'>", _joinArray("<attribute name='", columnSet, "' />"), _joinArray("<order attribute='", orderby, "' />"), " <filter>", _joinConditionPair(attributes, values), " </filter>", " </entity>", "</fetch>"].join(""); return _fetch(xml, callback) }; var _setState = function (entityName, id, stateCode, statusCode, callback) { var request = ["<Request xsi:type='SetStateDynamicEntityRequest'>", "<Entity>", "<Name xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entityName, "</Name>", "<Id xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", id, "</Id>", "</Entity>", "<State>", stateCode, "</State>", "<Status>", statusCode, "</Status>", "</Request>"].join(""); var async = !!callback; return _doRequest(request, "Execute", async, function (resultXml) { var response = resultXml.selectSingleNode("//ExecuteResponse/Response"); var result = CrmEncodeDecode.CrmXmlDecode(response.text); if (!async) { return result } else { callback(result) } }) }; var _associate = function (relationshipName, entity1Name, entity1Id, entity2Name, entity2Id, callback) { var request = ["<Request xsi:type='AssociateEntitiesRequest'>", "<Moniker1>", "<Id xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entity1Id, "</Id>", "<Name xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entity1Name, "</Name>", "</Moniker1>", "<Moniker2>", "<Id xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entity2Id, "</Id>", "<Name xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entity2Name, "</Name>", "</Moniker2>", "<RelationshipName>", relationshipName, "</RelationshipName>", "</Request>"].join(""); var async = !!callback; return _doRequest(request, "Execute", async, function (resultXml) { var response = resultXml.selectSingleNode("//ExecuteResponse/Response"); var result = CrmEncodeDecode.CrmXmlDecode(response.text); if (!async) { return result } else { callback(result) } }) }; var _disassociate = function (relationshipName, entity1Name, entity1Id, entity2Name, entity2Id, callback) { var request = ["<Request xsi:type='DisassociateEntitiesRequest'>", "<Moniker1>", "<Id xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entity1Id, "</Id>", "<Name xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entity1Name, "</Name>", "</Moniker1>", "<Moniker2>", "<Id xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entity2Id, "</Id>", "<Name xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entity2Name, "</Name>", "</Moniker2>", "<RelationshipName>", relationshipName, "</RelationshipName>", "</Request>"].join(""); var async = !!callback; return _doRequest(request, "Execute", async, function (resultXml) { var response = resultXml.selectSingleNode("//ExecuteResponse/Response"); var result = CrmEncodeDecode.CrmXmlDecode(response.text); if (!async) { return result } else { callback(result) } }) }; var _getCurrentUserRoles = function () { var xml = ["<fetch mapping='logical'>", " <entity name='role'>", " <attribute name='name' />", " <link-entity name='systemuserroles' from='roleid' to='roleid' link-type='inner'>", " <filter>", " <condition attribute='systemuserid' operator='eq-userid' />", " </filter>", " <link-entity name='systemuser' from='systemuserid' to='systemuserid' link-type='inner' />", " </link-entity>", " </entity>", "</fetch>"].join(""); var fetchResult = _fetch(xml); var roles = []; if (fetchResult !== null) { for (var i = 0; i < fetchResult.length; i++) { roles[i] = fetchResult[i].getValue("name") } } return roles }; var _getCurrentUserId = function () { var request = "<Request xsi:type='WhoAmIRequest' />"; var xmlDoc = _doRequest(request, "Execute"); return xmlDoc.getElementsByTagName("UserId")[0].childNodes[0].nodeValue }; var _isCurrentUserInRole = function () { var roles = _getCurrentUserRoles(); for (var i = 0; i < roles.length; i++) { for (var j = 0; j < arguments.length; j++) { if (roles[i] === arguments[j]) { return true } } } return false }; var _padNumber = function (s, len) { len = len || 2; s = "" + s; while (s.length < len) { s = "0" + s } return s }; var _getDatePart = function (s) { s = s.replace(/^0+(.)$/, "$1"); return parseInt(s) }; var _parseDate = function (s) { if (s == null || !s.match(_dateTimeExpr)) { return null } var dateParts = _dateTimeExpr.exec(s); return new Date(_getDatePart(dateParts[1]), _getDatePart(dateParts[2]) - 1, _getDatePart(dateParts[3]), _getDatePart(dateParts[4]), _getDatePart(dateParts[5]), _getDatePart(dateParts[6])) }; var _encodeDate = function (dateTime) { return dateTime.getFullYear() + "-" + _padNumber(dateTime.getMonth() + 1) + "-" + _padNumber(dateTime.getDate()) + "T" + _padNumber(dateTime.getHours()) + ":" + _padNumber(dateTime.getMinutes()) + ":" + _padNumber(dateTime.getSeconds()) }; var _parseResultXmlNode = function (fieldNode) { var field = {}; for (var k = 0; k < fieldNode.attributes.length; k++) { field[fieldNode.attributes[k].nodeName] = CrmEncodeDecode.CrmXmlDecode(fieldNode.attributes[k].nodeValue) } var nodeText = CrmEncodeDecode.CrmXmlDecode(fieldNode.text); if (fieldNode.attributes.length === 1 && fieldNode.getAttribute("formattedvalue") !== null && nodeText.match(_numberExpr)) { if (!nodeText.indexOf(".")) { field["$value"] = parseInt(nodeText) } else { field["$value"] = parseFloat(nodeText) } } else { if (fieldNode.attributes.length === 2 && fieldNode.getAttribute("formattedvalue") !== null && fieldNode.getAttribute("name") !== null && nodeText.match(_integerExpr)) { field["$value"] = parseInt(nodeText) } else { if (fieldNode.attributes.length === 1 && fieldNode.getAttribute("name") !== null && nodeText.match(_integerExpr)) { field["$value"] = parseInt(nodeText) } else { if (fieldNode.attributes.length === 2 && fieldNode.getAttribute("date") !== null && fieldNode.getAttribute("time") !== null && nodeText.match(_dateTimeExpr)) { field["$value"] = _parseDate(nodeText) } else { field["$value"] = nodeText } } } } return field }; var _encodeValue = function (value) { return (typeof value === "object" && value.getTime) ? _encodeDate(value) : CrmEncodeDecode.CrmXmlEncode(value) }; var _businessEntity = function (entityName) { this.name = entityName; this.attributes = {} }; _businessEntity.prototype = { getValue: function (field, attribute) { if (this === null || !this.attributes.hasOwnProperty(field)) { return null } return (attribute === undefined) ? this.attributes[field]["$value"] : this.attributes[field][attribute] }, getValueAsBoolean: function (field) { if (this === null || !this.attributes.hasOwnProperty(field)) { return null } return (this.attributes[field]["$value"] == 1) }, getValueAsLookup: function (field, typename) { if (this === null || !this.attributes.hasOwnProperty(field)) { return null } if (!this.attributes[field].hasOwnProperty("name")) { throw new Error("'" + field + "' does not seem to be a CRM lookup field. ") } return [{ id: this.attributes[field]["$value"], typename: typename, name: this.attributes[field]["name"]}] }, serialize: function () { var xml = ['<entity xsi:type="', this.name, '">']; for (var attributeName in this.attributes) { var attribute = this.attributes[attributeName]; var value = attribute["$value"] || attribute; var encodedValue = _encodeValue(value); var type = (!attribute.type) ? "" : ' type="' + CrmEncodeDecode.CrmXmlEncode(attribute.type) + '"'; xml.push("<", attributeName, type, ">", encodedValue, "</", attributeName, ">") } xml.push("</entity>"); return xml.join("") }, deserialize: function (resultNode) { var resultNodes = resultNode.childNodes; for (var i = 0; i < resultNodes.length; i++) { var fieldNode = resultNodes[i]; this.attributes[fieldNode.baseName] = _parseResultXmlNode(fieldNode) } } }; return { BusinessEntity: _businessEntity, Retrieve: _retrieve, RetrieveMultiple: _retrieveMultiple, Fetch: _fetch, Execute: _execute, Create: _create, Update: _update, Delete: _delete, queryByAttribute: _queryByAttribute, setState: _setState, associate: _associate, disassociate: _disassociate, isCurrentUserInRole: _isCurrentUserInRole, getCurrentUserRoles: _getCurrentUserRoles, getCurrentUserId: _getCurrentUserId, parseDate: _parseDate, encodeDate: _encodeDate} } ();
/********************************CRM Toolkit************************/
crmForm.all.ws_opportunitynumber.Disabled = false;
var numberingGuid = "";
switch (crmForm.all.ws_bidtype.SelectedText) {
case "Service":
numberingGuid = "F3A4A2D2-624E-E011-9D2F-005056AE0007";
break;
case "Project":
numberingGuid = "ADF4C3CA-624E-E011-9D2F-005056AE0007";
break;
case "Project - Change":
numberingGuid = "6447FA30-777A-E111-9805-005056AE0007";
break;
case "Maintenance":
numberingGuid = "1390FF84-624E-E011-9D2F-005056AE0007";
break;
case "Maintenance - Addition":
numberingGuid = "592BD492-624E-E011-9D2F-005056AE0007";
break;
case "Maintenance - Deduction":
numberingGuid = "4FF6D69F-624E-E011-9D2F-005056AE0007";
break;
case "Maintenance - Reprice":
numberingGuid = "73EEC5BD-624E-E011-9D2F-005056AE0007";
break;
case "Maintenance - Renewal":
numberingGuid = "9D7009AD-624E-E011-9D2F-005056AE0007";
break;
case "Controls":
numberingGuid = "A3E03677-624E-E011-9D2F-005056AE0007";
break;
case "Controls - Change":
numberingGuid = "4404EB44-777A-E111-9805-005056AE0007";
break;
case "AC Tuneup":
numberingGuid = "519B816E-624E-E011-9D2F-005056AE0007";
break;
case "Budget":
numberingGuid = "50A7AB65-65B2-E111-92E0-005056AE0007";
break;
case "Maintenance - Cancellation":
numberingGuid = "5FED34A9-68B2-E111-92E0-005056AE0007";
break;
}
var cols = ["new_nextnumber"];
switch (crmForm.FormType) {
case 1: //new - create
var retreivedNumber = CrmServiceToolkit.Retrieve("new_numberingmaster", numberingGuid, cols);
var numberingmaster = new CrmServiceToolkit.BusinessEntity("new_numberingmaster");
numberingmaster.attributes["new_numberingmasterid"] = numberingGuid;
numberingmaster.attributes["new_nextnumber"] = retreivedNumber.getValue("new_nextnumber") + 1;
var updateresponse = CrmServiceToolkit.Update(numberingmaster);
break;
}
return true;
}
function new_bidtype_onchange()
{
/********************************CRM Toolkit************************/
/**
* MSCRM4 Web Service Toolkit for JavaScript v2.1
* @author Daniel Cai, http://danielcai.blogspot.com/
* @license Microsoft Public License (Ms-PL), www.opensource.org/.../ms-pl.html
* Date: July 4, 2010
*/
CrmServiceToolkit = function () { var _dateTimeExpr = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})[\.\d{3}]?([-+]\d{2}):(\d{2})$/, _numberExpr = /^[-+]?\d*\.?\d*$/, _integerExpr = /^[0-9]\d*$/; var _doRequest = function (soapBody, requestType, async, internalCallback) { async = async || false; var soapXml = ["<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>", GenerateAuthenticationHeader(), "<soap:Body>", "<", requestType, " xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>", soapBody, "</", requestType, ">", "</soap:Body>", "</soap:Envelope>"].join(""); var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); xmlhttp.open("POST", "/MSCRMServices/2007/crmservice.asmx", async); xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xmlhttp.setRequestHeader("SOAPAction", "schemas.microsoft.com/.../WebServices" + requestType); xmlhttp.send(soapXml); if (async) { xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { internalCallback(_processResponse(xmlhttp.responseXML, xmlhttp.responseText)) } else { throw new Error("HTTP-Requests ERROR: " + xmlhttp.statusText) } } } } else { var result = _processResponse(xmlhttp.responseXML); return !!internalCallback ? internalCallback(result) : result } }; var _processResponse = function (responseXml, responseText) { if (responseXml === null || responseXml.xml === null || responseXml.xml === "") { if (responseText !== null && responseText !== "") { throw new Error(responseText) } else { throw new Error("No response received from the server. ") } } var error = responseXml.selectSingleNode("//error"); var faultString = responseXml.selectSingleNode("//faultstring"); if (error !== null || faultString !== null) { throw new Error(error !== null ? responseXml.selectSingleNode("//description").nodeTypedValue : faultString.text) } var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = false; xmlDoc.loadXML(responseXml.xml); return xmlDoc }; var _fetch = function (fetchXml, callback) { var msgBody = "<fetchXml>" + _HtmlEncode(fetchXml) + "</fetchXml>"; var async = !!callback; return _doRequest(msgBody, "Fetch", !!callback, function (resultXml) { var fetchResult = resultXml.selectSingleNode("//FetchResult"); resultXml.loadXML(fetchResult.childNodes[0].nodeValue); var resultNodes = resultXml.selectNodes("/resultset/result"); var results = []; for (var i = 0; i < resultNodes.length; i++) { var entity = new _businessEntity(); entity.deserialize(resultNodes[i]); results[i] = entity } if (!async) { return results } else { callback(results) } }) }; var _retrieve = function (entityName, id, columnSet, callback) { var attributes = ""; if (columnSet !== undefined) { for (var i = 0; i < columnSet.length; i++) { attributes += "<q1:Attribute>" + columnSet[i] + "</q1:Attribute>" } } var msgBody = ["<entityName>", entityName, "</entityName>", "<id>", id, "</id>", "<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>", "<q1:Attributes>", attributes, "</q1:Attributes>", "</columnSet>"].join(""); var async = !!callback; return _doRequest(msgBody, "Retrieve", !!callback, function (resultXml) { var retrieveResult = resultXml.selectSingleNode("//RetrieveResult"); var entity = new _businessEntity(); entity.deserialize(retrieveResult); if (!async) { return entity } else { callback(entity) } }) }; var _retrieveMultiple = function (query, callback) { var msgBody = ["<Request xsi:type='RetrieveMultipleRequest' ReturnDynamicEntities='false'>", "<Query xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:QueryExpression'>", query, "</Query>", "</Request>"].join(""); var async = !!callback; return _doRequest(msgBody, "Execute", async, function (resultXml) { var resultNodes = resultXml.selectNodes("//BusinessEntityCollection/BusinessEntities/BusinessEntity"); var results = []; for (var i = 0; i < resultNodes.length; i++) { var entity = new _businessEntity(); entity.deserialize(resultNodes[i]); results[i] = entity } if (!async) { return results } else { callback(results) } }) }; var _execute = function (request, callback) { var async = !!callback; return _doRequest(request, "Execute", async, function (resultXml) { if (!async) { return resultXml } else { callback(resultXml) } }) }; var _create = function (businessEntity, callback) { var request = businessEntity.serialize(); var async = !!callback; return _doRequest(request, "Create", async, function (resultXml) { var response = resultXml.selectSingleNode("//CreateResponse/CreateResult"); var result = CrmEncodeDecode.CrmXmlDecode(response.text); if (!async) { return result } else { callback(result) } }) }; var _update = function (businessEntity, callback) { var request = businessEntity.serialize(); var async = !!callback; return _doRequest(request, "Update", async, function (resultXml) { var response = resultXml.selectSingleNode("//UpdateResponse"); var result = CrmEncodeDecode.CrmXmlDecode(response.text); if (!async) { return result } else { callback(result) } }) }; var _delete = function (entityName, id, callback) { var request = ["<entityName>", entityName, "</entityName>", "<id>", id, "</id>"].join(""); var async = !!callback; return _doRequest(request, "Delete", async, function (resultXml) { var response = resultXml.selectSingleNode("//DeleteResponse"); var result = CrmEncodeDecode.CrmXmlDecode(response.text); if (!async) { return result } else { callback(result) } }) }; var _joinArray = function (prefix, array, suffix) { var output = []; for (var i = 0; i < array.length; i++) { if (array[i] != "" && array[i] != undefined) { output.push(prefix, array[i], suffix) } } return output.join("") }; var _joinConditionPair = function (attributes, values) { var output = []; for (var i = 0; i < attributes.length; i++) { if (attributes[i] != "") { output.push("<condition attribute='", attributes[i], "' operator='eq' value='", values[i], "' />") } } return output.join("") }; var _isArray = function (input) { return input.constructor.toString().indexOf("Array") != -1 }; var _queryByAttribute = function (queryOptions, callback) { var entityName = queryOptions.entityName; var attributes = queryOptions.attributes; var values = queryOptions.values; var columnSet = queryOptions.columnSet; var orderby = queryOptions.orderby || ""; attributes = _isArray(attributes) ? attributes : [attributes]; values = _isArray(values) ? values : [values]; orderby = (!!orderby && _isArray(orderby)) ? orderby : [orderby]; columnSet = (!!columnSet && _isArray(columnSet)) ? columnSet : [columnSet]; for (var i = 0; i < values.length; i++) { values[i] = _encodeValue(values[i]) } var xml = ["<fetch mapping='logical'>", " <entity name='", entityName, "'>", _joinArray("<attribute name='", columnSet, "' />"), _joinArray("<order attribute='", orderby, "' />"), " <filter>", _joinConditionPair(attributes, values), " </filter>", " </entity>", "</fetch>"].join(""); return _fetch(xml, callback) }; var _setState = function (entityName, id, stateCode, statusCode, callback) { var request = ["<Request xsi:type='SetStateDynamicEntityRequest'>", "<Entity>", "<Name xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entityName, "</Name>", "<Id xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", id, "</Id>", "</Entity>", "<State>", stateCode, "</State>", "<Status>", statusCode, "</Status>", "</Request>"].join(""); var async = !!callback; return _doRequest(request, "Execute", async, function (resultXml) { var response = resultXml.selectSingleNode("//ExecuteResponse/Response"); var result = CrmEncodeDecode.CrmXmlDecode(response.text); if (!async) { return result } else { callback(result) } }) }; var _associate = function (relationshipName, entity1Name, entity1Id, entity2Name, entity2Id, callback) { var request = ["<Request xsi:type='AssociateEntitiesRequest'>", "<Moniker1>", "<Id xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entity1Id, "</Id>", "<Name xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entity1Name, "</Name>", "</Moniker1>", "<Moniker2>", "<Id xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entity2Id, "</Id>", "<Name xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entity2Name, "</Name>", "</Moniker2>", "<RelationshipName>", relationshipName, "</RelationshipName>", "</Request>"].join(""); var async = !!callback; return _doRequest(request, "Execute", async, function (resultXml) { var response = resultXml.selectSingleNode("//ExecuteResponse/Response"); var result = CrmEncodeDecode.CrmXmlDecode(response.text); if (!async) { return result } else { callback(result) } }) }; var _disassociate = function (relationshipName, entity1Name, entity1Id, entity2Name, entity2Id, callback) { var request = ["<Request xsi:type='DisassociateEntitiesRequest'>", "<Moniker1>", "<Id xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entity1Id, "</Id>", "<Name xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entity1Name, "</Name>", "</Moniker1>", "<Moniker2>", "<Id xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entity2Id, "</Id>", "<Name xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>", entity2Name, "</Name>", "</Moniker2>", "<RelationshipName>", relationshipName, "</RelationshipName>", "</Request>"].join(""); var async = !!callback; return _doRequest(request, "Execute", async, function (resultXml) { var response = resultXml.selectSingleNode("//ExecuteResponse/Response"); var result = CrmEncodeDecode.CrmXmlDecode(response.text); if (!async) { return result } else { callback(result) } }) }; var _getCurrentUserRoles = function () { var xml = ["<fetch mapping='logical'>", " <entity name='role'>", " <attribute name='name' />", " <link-entity name='systemuserroles' from='roleid' to='roleid' link-type='inner'>", " <filter>", " <condition attribute='systemuserid' operator='eq-userid' />", " </filter>", " <link-entity name='systemuser' from='systemuserid' to='systemuserid' link-type='inner' />", " </link-entity>", " </entity>", "</fetch>"].join(""); var fetchResult = _fetch(xml); var roles = []; if (fetchResult !== null) { for (var i = 0; i < fetchResult.length; i++) { roles[i] = fetchResult[i].getValue("name") } } return roles }; var _getCurrentUserId = function () { var request = "<Request xsi:type='WhoAmIRequest' />"; var xmlDoc = _doRequest(request, "Execute"); return xmlDoc.getElementsByTagName("UserId")[0].childNodes[0].nodeValue }; var _isCurrentUserInRole = function () { var roles = _getCurrentUserRoles(); for (var i = 0; i < roles.length; i++) { for (var j = 0; j < arguments.length; j++) { if (roles[i] === arguments[j]) { return true } } } return false }; var _padNumber = function (s, len) { len = len || 2; s = "" + s; while (s.length < len) { s = "0" + s } return s }; var _getDatePart = function (s) { s = s.replace(/^0+(.)$/, "$1"); return parseInt(s) }; var _parseDate = function (s) { if (s == null || !s.match(_dateTimeExpr)) { return null } var dateParts = _dateTimeExpr.exec(s); return new Date(_getDatePart(dateParts[1]), _getDatePart(dateParts[2]) - 1, _getDatePart(dateParts[3]), _getDatePart(dateParts[4]), _getDatePart(dateParts[5]), _getDatePart(dateParts[6])) }; var _encodeDate = function (dateTime) { return dateTime.getFullYear() + "-" + _padNumber(dateTime.getMonth() + 1) + "-" + _padNumber(dateTime.getDate()) + "T" + _padNumber(dateTime.getHours()) + ":" + _padNumber(dateTime.getMinutes()) + ":" + _padNumber(dateTime.getSeconds()) }; var _parseResultXmlNode = function (fieldNode) { var field = {}; for (var k = 0; k < fieldNode.attributes.length; k++) { field[fieldNode.attributes[k].nodeName] = CrmEncodeDecode.CrmXmlDecode(fieldNode.attributes[k].nodeValue) } var nodeText = CrmEncodeDecode.CrmXmlDecode(fieldNode.text); if (fieldNode.attributes.length === 1 && fieldNode.getAttribute("formattedvalue") !== null && nodeText.match(_numberExpr)) { if (!nodeText.indexOf(".")) { field["$value"] = parseInt(nodeText) } else { field["$value"] = parseFloat(nodeText) } } else { if (fieldNode.attributes.length === 2 && fieldNode.getAttribute("formattedvalue") !== null && fieldNode.getAttribute("name") !== null && nodeText.match(_integerExpr)) { field["$value"] = parseInt(nodeText) } else { if (fieldNode.attributes.length === 1 && fieldNode.getAttribute("name") !== null && nodeText.match(_integerExpr)) { field["$value"] = parseInt(nodeText) } else { if (fieldNode.attributes.length === 2 && fieldNode.getAttribute("date") !== null && fieldNode.getAttribute("time") !== null && nodeText.match(_dateTimeExpr)) { field["$value"] = _parseDate(nodeText) } else { field["$value"] = nodeText } } } } return field }; var _encodeValue = function (value) { return (typeof value === "object" && value.getTime) ? _encodeDate(value) : CrmEncodeDecode.CrmXmlEncode(value) }; var _businessEntity = function (entityName) { this.name = entityName; this.attributes = {} }; _businessEntity.prototype = { getValue: function (field, attribute) { if (this === null || !this.attributes.hasOwnProperty(field)) { return null } return (attribute === undefined) ? this.attributes[field]["$value"] : this.attributes[field][attribute] }, getValueAsBoolean: function (field) { if (this === null || !this.attributes.hasOwnProperty(field)) { return null } return (this.attributes[field]["$value"] == 1) }, getValueAsLookup: function (field, typename) { if (this === null || !this.attributes.hasOwnProperty(field)) { return null } if (!this.attributes[field].hasOwnProperty("name")) { throw new Error("'" + field + "' does not seem to be a CRM lookup field. ") } return [{ id: this.attributes[field]["$value"], typename: typename, name: this.attributes[field]["name"]}] }, serialize: function () { var xml = ['<entity xsi:type="', this.name, '">']; for (var attributeName in this.attributes) { var attribute = this.attributes[attributeName]; var value = attribute["$value"] || attribute; var encodedValue = _encodeValue(value); var type = (!attribute.type) ? "" : ' type="' + CrmEncodeDecode.CrmXmlEncode(attribute.type) + '"'; xml.push("<", attributeName, type, ">", encodedValue, "</", attributeName, ">") } xml.push("</entity>"); return xml.join("") }, deserialize: function (resultNode) { var resultNodes = resultNode.childNodes; for (var i = 0; i < resultNodes.length; i++) { var fieldNode = resultNodes[i]; this.attributes[fieldNode.baseName] = _parseResultXmlNode(fieldNode) } } }; return { BusinessEntity: _businessEntity, Retrieve: _retrieve, RetrieveMultiple: _retrieveMultiple, Fetch: _fetch, Execute: _execute, Create: _create, Update: _update, Delete: _delete, queryByAttribute: _queryByAttribute, setState: _setState, associate: _associate, disassociate: _disassociate, isCurrentUserInRole: _isCurrentUserInRole, getCurrentUserRoles: _getCurrentUserRoles, getCurrentUserId: _getCurrentUserId, parseDate: _parseDate, encodeDate: _encodeDate} } ();
/********************************CRM Toolkit************************/
switch (crmForm.all.ws_bidtype.SelectedText) {
case "Service":
numberingGuid = "F3A4A2D2-624E-E011-9D2F-005056AE0007";
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
break;
case "Project":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
numberingGuid = "ADF4C3CA-624E-E011-9D2F-005056AE0007";
break;
case "Project - Change":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
numberingGuid = "6447FA30-777A-E111-9805-005056AE0007";
break;
case "Maintenance - Renewal":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.new_contractvalue_c.style.visibility = "";
crmForm.all.new_contractvalue_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
numberingGuid = "9D7009AD-624E-E011-9D2F-005056AE0007";
break;
case "Maintenance":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
numberingGuid = "1390FF84-624E-E011-9D2F-005056AE0007";
break;
case "Maintenance - Addition":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
numberingGuid = "592BD492-624E-E011-9D2F-005056AE0007";
break;
case "Maintenance - Deduction":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
numberingGuid = "4FF6D69F-624E-E011-9D2F-005056AE0007";
break;
case "Maintenance - Reprice":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
numberingGuid = "73EEC5BD-624E-E011-9D2F-005056AE0007";
break;
case "Controls":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
numberingGuid = "A3E03677-624E-E011-9D2F-005056AE0007";
break;
case "Controls - Change":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
numberingGuid = "4404EB44-777A-E111-9805-005056AE0007";
break;
case "AC Tuneup":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
numberingGuid = "519B816E-624E-E011-9D2F-005056AE0007";
break;
case "Budget":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
numberingGuid = "50A7AB65-65B2-E111-92E0-005056AE0007";
break;
case "Maintenance - Cancellation":
crmForm.all.new_parentopportunity_c.style.visibility = "";
crmForm.all.new_parentopportunity_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_d.style.visibility = "";
crmForm.all.ws_estprojectenddate_c.style.visibility = "";
numberingGuid = "5FED34A9-68B2-E111-92E0-005056AE0007";
break;
}
var cols = ["new_prefix", "new_nextnumber"];
var retreivedNumber = CrmServiceToolkit.Retrieve("new_numberingmaster", numberingGuid, cols);
crmForm.all.ws_opportunitynumber.DataValue = retreivedNumber.getValue("new_prefix") + retreivedNumber.getValue("new_nextnumber");
}
function estimatedvalue_onchange()
{
crmForm.all.ws_grossmarginpercentage.DataValue = (crmForm.all.ws_estimatedgrossmargin.DataValue / crmForm.all.estimatedvalue.DataValue) * 100;
}
function new_estimatedgrossmargin_onchange()
{
crmForm.all.ws_grossmarginpercentage.DataValue = (crmForm.all.ws_estimatedgrossmargin.DataValue / crmForm.all.estimatedvalue.DataValue) * 100;
}I'm not certain what references need to be changed to ? Can I just substitute 2007 with 2011 ?
Thank you