Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Not able to save the Record by using Kendo HTML Grid

(0) ShareShare
ReportReport
Posted on by 155

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

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans