Reputation: 3764
I'm trying to pull back the GUID of a view to set a default lookup value in javascript. The rest of my code works if I hard code the variables, but that's not good development practice (though, pulling back a unique identifier by querying on a non-unique identifier isn't great either, but its better). I'm not sure how to form the ajax call though.
Here is a shell of what I am working with, I just don't know what to put at the end of /CRMServices/2011/OrganizationData.svc/ to get the proper record from the API. The Views are savedquery entities, so /savedquerySet makes sense but I'm not sure how to tell it to look up by name. I've not used this API a lot, and the documentation is confusing for me.
var b = Xrm.Page.context.getServerUrl() + "/XRMServices/2011/OrganizationData.svc/savedquerySet (<something here not sure what>)";
$.ajax({
type: "GET",
datatype: "json",
url: b,
beforeSend: function (a) {
a.setRequestHeader("Accept", "application/json")
},
success: function (a) {
var b = a.d;
SetGuid(b.SavedQueryIdUnique); // defined function
}
})
the field I am trying to query on is Name.
Help is very appreciated. This is in CRM 2011 UR 8 or so
Upvotes: 1
Views: 230
Reputation: 18061
Your REST query should look something like this:
/SavedQuerySet?$select=SavedQueryId&$filter=Name%20eq%20'YOUR VIEW NAME HERE'
The SavedQuerySet
name is case sensitive, as well as the attribute name in the select
(and filter) clause.
See the MSDN documentation on the ODATA endpoint for details.
Upvotes: 1