Call the Below Function onLoad & On-change Event.
// JScript source code
function ChangeCurrencyLookUpDisplayValue() {
debugger;
var lookupData = new Array();
var lookupItem = new Object();
var lookup = Xrm.Page.data.entity.attributes.get("transactioncurrencyid");
if (lookup != null) {
var displayvalue = '';
var xmlText = '';
xmlText += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"; xmlText += "<s:Body>";
xmlText += "<Retrieve xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance">";
xmlText += "<entityName>transactioncurrency</entityName>";
xmlText += "<id>" + lookup.getValue()[0].id + "</id>";
xmlText += "<columnSet xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\">";
xmlText += "<a:AllColumns>false</a:AllColumns>";
xmlText += "<a:Columns xmlns:b=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">";
xmlText += "<b:string>isocurrencycode</b:string>";
xmlText += "</a:Columns>";
xmlText += "</columnSet>";
xmlText += "</Retrieve>";
xmlText += "</s:Body>";
xmlText += "</s:Envelope>";
var xHReq = new XMLHttpRequest();
var url = Xrm.Page.context.getClientUrl() + "/XRMServices/2011/Organization.svc/web";
xHReq.open("POST", url, false);
xHReq.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Retrieve");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Accept", "application/xml,text/xml,*/*");
xHReq.send(xmlText);
//Capture the result.
var resultXml = xHReq.responseXML;
var varray = new Array();
//Check forerrors.
var result = resultXml.getElementsByTagName("a:KeyValuePairOfstringanyType");
if (result.length > 0) {
displayvalue = result[0].childNodes[1].lastChild.data;
}
if (displayvalue != '') {
lookupItem.name = displayvalue;
lookupData[0] = lookupItem;
lookup.DataValue = lookupData;
Xrm.Page.getAttribute("transactioncurrencyid").
setValue([{
id: lookup.getValue()[0].id,
name: displayvalue, entityType: "transactioncurrency"
}]);
}
}
}
// JScript source code
function ChangeCurrencyLookUpDisplayValue() {
debugger;
var lookupData = new Array();
var lookupItem = new Object();
var lookup = Xrm.Page.data.entity.attributes.get("transactioncurrencyid");
if (lookup != null) {
var displayvalue = '';
var xmlText = '';
xmlText += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"; xmlText += "<s:Body>";
xmlText += "<Retrieve xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance">";
xmlText += "<entityName>transactioncurrency</entityName>";
xmlText += "<id>" + lookup.getValue()[0].id + "</id>";
xmlText += "<columnSet xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\">";
xmlText += "<a:AllColumns>false</a:AllColumns>";
xmlText += "<a:Columns xmlns:b=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">";
xmlText += "<b:string>isocurrencycode</b:string>";
xmlText += "</a:Columns>";
xmlText += "</columnSet>";
xmlText += "</Retrieve>";
xmlText += "</s:Body>";
xmlText += "</s:Envelope>";
var xHReq = new XMLHttpRequest();
var url = Xrm.Page.context.getClientUrl() + "/XRMServices/2011/Organization.svc/web";
xHReq.open("POST", url, false);
xHReq.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Retrieve");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Accept", "application/xml,text/xml,*/*");
xHReq.send(xmlText);
//Capture the result.
var resultXml = xHReq.responseXML;
var varray = new Array();
//Check forerrors.
var result = resultXml.getElementsByTagName("a:KeyValuePairOfstringanyType");
if (result.length > 0) {
displayvalue = result[0].childNodes[1].lastChild.data;
}
if (displayvalue != '') {
lookupItem.name = displayvalue;
lookupData[0] = lookupItem;
lookup.DataValue = lookupData;
Xrm.Page.getAttribute("transactioncurrencyid").
setValue([{
id: lookup.getValue()[0].id,
name: displayvalue, entityType: "transactioncurrency"
}]);
}
}
}
No comments:
Post a Comment