Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Error in calling Xrm.WebApi.retrieveMultipleRecords

Posted on by 12,070 Super User 2024 Season 1

Hi all, 

I am using below code:

//<-------------------- Ribbon Button Commands -------------------->
function clickSubmitBtn(recordID) {
debugger
Validate_POLines("msdyn_purchaseorder", recordID);
if (validate.isPOContainsLine) {
SetLookUp("msdyn_substatus", "msdyn_purchaseordersubstatus", "15818160-c7f9-e711-a829-000d3ab488e0", "Submitted");
Xrm.Page.data.entity.save();
}
}
//<-------------------- Ribbon Button Commands -------------------->

function Validate_POLines(entityLogicalName, guid) {
debugger;
var guidd = guid;
guid = guid.replace(/[{}]/g, "");
/*xrm.WebApi.retrieveRecord(entityLogicalName, guid, "?$select=msdyn_name&$expand=msdyn_purchaseorder($select=msdyn_purchaseorderproduct,msdyn_name)").then(
function success(result) {
//console.log('Retrieved values: Name: ${result.name}, Primary Contact ID: ${result.primarycontactid.contactid}, Primary Contact Name: ${result.primarycontactid.fullname}');
// perform operations on record retrieval
validate.isPOContainLine = true;
},
function (error) {
console.log(error.message);
// handle error conditions
}
);*/
//create the query
try {
//var queryOption = "?$select=msdyn_name&$filter=(msdyn_purchaseorder eq '" + guid + "')";
//var queryOption = "?$select=msdyn_name&$filter=msdyn_purchaseorder eq " + guid;
var queryOption = "?$select=msdyn_name&$filter=msdyn_purchaseorder/id eq (guid'" + guid + "')";
var queryOption = "?$select=msdyn_name&$filter=msdyn_purchaseorder/id eq (guid'" + guidd + "')";
var queryOption = "?$select=msdyn_name&$filter=msdyn_purchaseorder/id eq " + guid;
var queryOption = "?$select=msdyn_name&$filter=msdyn_purchaseorder/id eq " + guidd;
var queryOption = "?$select=msdyn_name&$filter=msdyn_purchaseorder eq (guid'" + guid + "')";
var queryOption = "?$select=msdyn_name&$filter=msdyn_purchaseorder eq (guid'" + guidd + "')";
var queryOption = "?$select=msdyn_name&$filter=_msdyn_purchaseorder_value eq (guid'" + guid + "')";
var queryOption = "?$select=msdyn_name&$filter=_msdyn_purchaseorder_value eq " + guid;

//execute the query and get the results
Xrm.WebApi.retrieveMultipleRecords("msdyn_purchaseorderproducts", queryOption)
.then(function (data) {
//retrieveContactSuccess(data.entities);
validate.isPOContainsLine = true;
})
.fail(function (error) {
Xrm.Utility.alertDialog(error.message);
});
} catch (e) {
Xrm.Utility.alertDialog(e);
}
}

and having below errors:

Unrecognized 'Edm.String' literal 'guid'77EDFDE2-3DFC-E711-A829-000D3AB4831F'' at '25' in '(msdyn_purchaseorder eq (guid'77EDFDE2-3DFC-E711-A829-000D3AB4831F')'.

 

1. A binary operator with incompatible types was detected. Found operand types 'Microsoft.Dynamics.CRM.msdyn_purchaseorder' and 'Edm.String' for operator kind 'Equal'.

 

2. A binary operator with incompatible types was detected. Found operand types 'Edm.Guid' and 'Edm.String' for operator kind 'Equal'.

 

3. error = XrmClientApi.ErrorResponse {errorCode: 0, message: "Unrecognized 'Edm.String' literal 'guid'891922C0-C…eq (guid'891922C0-CC43-E811-A834-000D3AB48E2A')'.", debugMessage: "", innerError: {…}, innerror: {…}}

I need help and this is urgent

*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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans