Dear Experts,
1.This is my Row Column
columnArray.push(
{
name: "pcl_typeofdealer",
type: "EntityReference",
required: true,
editable: true,
title: "Type of Dealer ",
width: "45px",
editor: TypeofDealer3
});
2.here am binding type of dealer field to grid
function TypeofDealer3(container, options) {
debugger;
jQuery('<input data-text-field="name" data-value-field="id" data-bind="id:' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList(
{
dataTextField: "name",
dataValueField: "id",
dataSource: RetrieveEntityReferenceMetaDataTOD3(options.field),
optionLabel: {
name: "",
id: -1,
type: "EntityReference"
}
});
}
3.here am Retrieving the EntityReference
function RetrieveEntityReferenceMetaDataTOD3(field) {
debugger;
//// var reqID = window.parent.Xrm.Page.data.entity.getId();
// debugger;
/// var primaryObjectiveData = RetrieveType();
var data = [];
//// var grid = $("#grid").data("kendoGrid");
//// var selectedItem = data1;
var fetchXml = "";
fetchXml += "<fetch distinct='false' mapping='logical' output-format='xml-platform' version='1.0'>";
fetchXml += "<entity name='lead'>";
fetchXml += "<attribute name='fullname'/>";
fetchXml += "<attribute name='companyname'/>";
fetchXml += "<attribute name='telephone1'/>";
fetchXml += "<attribute name='leadid'/>";
fetchXml += "<order descending='false' attribute='fullname'/>";
fetchXml += "</entity></fetch>";
var collection = RetrieveRecord(fetchXml);
var record = {};
record.id = -1;
record.name = "";
data.push(record);
for (var i = 0; i < collection.length; i++) {
var record = {};
record.id = collection[i].id.toString();
if (collection[i].attributes.fullname != undefined) {
record.name = collection[i].attributes.fullname.value + " ";
}
else {
record.name = " ";
}
record.type = "EntityReference";
//record.name = collection[i].logicalName.toString();
data.push(record);
}
return data;
}
4.this data am pushing to Appointment Entity
so first am fetching the attribute from Appointment Entity Like bellow
" <attribute name='pcl_typeofdealer' />" +
if (collection[i].attributes.pcl_typeofdealer != null && collection[i].attributes.pcl_typeofdealer != undefined)
{
var typeDealer = {};
typeDealer.name = collection[i].attributes.pcl_typeofdealer.name;
typeDealer.id = collection[i].attributes.pcl_typeofdealer.id;
typeDealer.type = "EntityReference";
record.pcl_typeofdealer = typeDealer;
// entity.attributes["pcl_typeofdealer"] = { id: leadid, logicalName: "new_student", type: "EntityReference" };
}
5.Here am Creating the Record but am not able to save the record in Appointment
if (EntityObj.data.pcl_typeofdealer != null && EntityObj.data.pcl_typeofdealer != undefined) {
createRecord.attributes["pcl_typeofdealer"] = {
id: EntityObj.data.pcl_typeofdealer.id,
name: EntityObj.data.pcl_typeofdealer.name,
type: 'EntityReference',
logicalName: 'lead'
//entityType: "pcl_travelplan"
}
}
Can any Please Help me on this
thanks
shankar
*This post is locked for comments