There are 2 entities named contact and offer(custom entity).There is a 1:N relationship from contact to offer entity.there is also a subgrid of offer in contact entity and a ribbon button named next best offer,the requirement is when the ribbon button is hitted a new offer record is created ,whose name is Freedom rewards.But iam not getting the record created after hitting the button.My code is given below:
function subgrid()
{
var contactId = Xrm.Page.data.entity.getId();
var createofferforCC = new XrmServiceToolkit.Soap.BusinessEntity("cgfs_offer");
createofferforCC.attributes["cgfs_name"] = "Freedom Rewards";
createofferforCC.attributes["cgfs_customer"] = { id: contactId, logicalName: "contact", type: "EntityReference" };
XrmServiceToolkit.Soap.Create(createofferforCC);
Xrm.Page.ui.controls.get("Offers").refresh();
}