function GetDetails()
{
var EntityName, EntityId, LookupFieldObject;
//LookupFieldObject = Xrm.Page.data.entity.attributes.get('new_studentid');
LookupFieldObject = Xrm.Page.data.entity.attributes.get('cms_batch');
// If lookup field has value then the code will only run
if (LookupFieldObject.getValue() != null)
{
//Fetch and place Entity Id (GUID) and Name (String) form lookup field into local variables
EntityId = LookupFieldObject.getValue()[0].id;
//EntityName = LookupFieldObject.getValue()[0].entityType;
var obj = RecRetrieve(EntityId, "cms_batch");
// In retrieved XML document check if it has accountnumber attribute
//below is code to retrieve and set lookup
if (obj.cms_MeritCriteria.Id != null )
{
var lookupData = new Array();
//Create an Object add to the array.
var lookupItem= new Object();
lookupItem.id = obj.cms_MeritCriteria.Id;
lookupItem.typename = 'cms_meritcriteria';
lookupItem.name = obj.cms_MeritCriteria.Name;
lookupData[0] = lookupItem;
// Set the value of the lookup field to the value of the array.
Xrm.Page.getAttribute("cms_meritcriteria").setValue(lookupData);
Xrm.Page.getAttribute("cms_meritcriteria").setSubmitMode("always");
}
else
{
Xrm.Page.data.entity.attributes.get('cms_meritcriteria').setValue(null);
}
}
}
function RecRetrieve(_id, _entityname)
{
var _result;
XrmSvcToolkit.retrieve({
entityName: _entityname,//"Contact",
id: _id,//, 1FED44D1-AE68-4A41-BD2B-F13ACAC4ACFA//
async: false,
successCallback: function (result)
{
_result = result;
},
errorCallback: function (error)
{
alert("Error");
}
});
return _result;
}
{
var EntityName, EntityId, LookupFieldObject;
//LookupFieldObject = Xrm.Page.data.entity.attributes.get('new_studentid');
LookupFieldObject = Xrm.Page.data.entity.attributes.get('cms_batch');
// If lookup field has value then the code will only run
if (LookupFieldObject.getValue() != null)
{
//Fetch and place Entity Id (GUID) and Name (String) form lookup field into local variables
EntityId = LookupFieldObject.getValue()[0].id;
//EntityName = LookupFieldObject.getValue()[0].entityType;
var obj = RecRetrieve(EntityId, "cms_batch");
// In retrieved XML document check if it has accountnumber attribute
//below is code to retrieve and set lookup
if (obj.cms_MeritCriteria.Id != null )
{
var lookupData = new Array();
//Create an Object add to the array.
var lookupItem= new Object();
lookupItem.id = obj.cms_MeritCriteria.Id;
lookupItem.typename = 'cms_meritcriteria';
lookupItem.name = obj.cms_MeritCriteria.Name;
lookupData[0] = lookupItem;
// Set the value of the lookup field to the value of the array.
Xrm.Page.getAttribute("cms_meritcriteria").setValue(lookupData);
Xrm.Page.getAttribute("cms_meritcriteria").setSubmitMode("always");
}
else
{
Xrm.Page.data.entity.attributes.get('cms_meritcriteria').setValue(null);
}
}
}
function RecRetrieve(_id, _entityname)
{
var _result;
XrmSvcToolkit.retrieve({
entityName: _entityname,//"Contact",
id: _id,//, 1FED44D1-AE68-4A41-BD2B-F13ACAC4ACFA//
async: false,
successCallback: function (result)
{
_result = result;
},
errorCallback: function (error)
{
alert("Error");
}
});
return _result;
}
No comments:
Post a Comment