Hi All,
I want to create a new record from the below two query, when i set the lookup value i am facing error, but when i use query with out lookup field it works fine. i have check the schema name, below are two was i have check,i am having system admin rights.
1)
var entity = {};
entity.name = "test";
entity["new_marketid@odata.bind"] = "/new_markets(xxxxxxxx-EF23-E411-A48E-xxxxxxxxx)";
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts",
data: JSON.stringify(entity),
beforeSend: function(XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("OData-MaxVersion", "4.0");
XMLHttpRequest.setRequestHeader("OData-Version", "4.0");
XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
async: true,
success: function(data, textStatus, xhr) {
var uri = xhr.getResponseHeader("OData-EntityId");
var regExp = /\(([^)]+)\)/;
var matches = regExp.exec(uri);
var newEntityId = matches[1];
},
error: function(xhr, textStatus, errorThrown) {
Xrm.Utility.alertDialog(textStatus + " " + errorThrown);
}
});
2)
var lookupValue = new Array();
lookupValue[0] = new Object();
lookupValue[0].id = "xxxxxxxx-EF23-E411-A48E-xxxxxx";
lookupValue[0].name = "A&E";
lookupValue[0].entityType = "new_markets";
var entity = new XrmServiceToolkit.Soap.BusinessEntity("account");
entity.attributes["name"] = "test";
entity.attributes["new_marketid"] = lookupValue;
var guid = XrmServiceToolkit.Soap.Create(entity);
Both the code not working when using lookup value.
Any help would be appreciated.
Regards,
Shahbaaz
*This post is locked for comments
I have the same question (0)