Tuesday, October 18, 2011

Creating a record using OData Service & JQuery

If you search in the net, you may find many examples of createing a record using OData Service & JQuery.
But in all these examples, you can see, that string values added to the entity object.
But how you are going to create a record which has a Lookup (Entity Refernce) value.

You can use following code


var entity = new Object();
entity.Subject = "subject goes here";
//Entity Reference (Also called as Lookup)
entity.RegardingObjectId = {
            Id: Xrm.Page.data.entity.getId(), 
            LogicalName: Xrm.Page.data.entity.getEntityName()
};

createRecord(
entity,
"new_entityNameSet",
 createAuditActionCompleted,
errorOnAuditCreate
);

No comments:

Post a Comment