I am work on some OData query calls to Microsoft CRM and need my query in a very specific format.I am passing parameters to a function which then adds the URL to my query. What I am passing my retrieve function is as follows:
webAPI.REST.retrieveEntity(
"EntityDefinition",
id,
+ "/Attributes(LogicalName='" + logicalAttribute + "')"
+ "/Microsoft.Dynamics.CRM.PicklistAttributeMetadata"
+ "?$select=LogicalName&$expand=OptionSet"
, null)
In debugging my parameter with the query options is:
"NaNmylogicalattribute')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet"
As you can see, my "/Attributes(LogicalName=" was replaced with "NaN". How do I prevent this from occurring?
Here is the problem:
id,
+ "/Attributes(LogicalName='" + logicalAttribute + "')"
Since you aren't starting with a String
, the leading +
is coercing your String
into a Number
(it isn't a Number
, hence NaN
). Just remove that first leading +
and it will work:
id,
"/Attributes(LogicalName='" + logicalAttribute + "')"