Xrm.Tools.CRMWebAPI
Xrm.Tools.CRMWebAPI copied to clipboard
parameter formatting in ExecuteFunctions adds quotes and sometimes you don't want them
I was issuing a Rollup function call and passing in an enum type that needs to format to @pX=Microsoft.Dynamics.CRM.RollupType'Extended'
but the function is adding the quotes in where it should not. Probably the best way to code this is to see if there are quotes in it already meaning that's already quoted/qualified or allow a function in its place that evaluates to the proper value to insert into the query parameter value. Otherwise, we have to use a wacky workaround. Related to #38.
Here's the code issue:
(key) {
var val = parameters[key];
parmvars.push(key + "=" + "@p" + parmcount.toString());
f (typeof val === 'string' || val instanceof String) parmvalues.push("@p" + parmcount.toString() + "='" + val + "'");
else parmvalues.push("@p" + parmcount.toString() + "=" + val);
parmcount++;
I worked around this by using:
function ToString(arg) { this.toString = function() { return arg } }
Then varToPassInParameters = new ToString("blah")
.
@aappddeevv can you share how you had formatted the API call that was causing the problem?
I don't have that because I used ToString hack. But I recall that it was an enum. I passed in the enum through qopts so your code would test for the string and wrap it again i quotes:
var param = "Microsoft.Dynamics.CRM.RollupType'Extended'"
makeTheCall(..., param, ...)
would become 'Microsoft.Dynamics.CRM.RollpType'Extended''
I think this was a Rollup ExecuteFunction call which requires an enum for the rollup type.