Search This Blog

Thursday, September 24, 2015

Create Record in related entity using javascript xrmservicetoolkit in crm 2013 and crm 2015

In this function i want to create record of department against School (School (1): Depattment(N))

function CreateRecord()
{
 var stdId = Xrm.Page.data.entity.getId();
var entity = {};
 entity.new_School = {
            Id: stdId,
            LogicalName: "new_department"//logical name of entity if which you want to create record
        };
entity.new_name = "test";

XrmServiceToolkit.Rest.Create(
    entity,
    "new_departmentSet",//
    function (result) {
         var newEntityId = result.new_departmentId;
    },
    function (error) {
         alert(error.message);
    },
    true
);
}

No comments:

Post a Comment