Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot convert values to String using $odata.Value("C068332","String") #79

Open
patrickdizon opened this issue Jul 15, 2016 · 0 comments

Comments

@patrickdizon
Copy link

patrickdizon commented Jul 15, 2016

I have an object for data types and search parameters:

var dataTypes = { CustomerNumber: "String", FirstName: "String", Orders: "Int" }
var params = { CustomerNumber: "C068211", FirstName: "John", Orders: 30}

But when I run this:

oData.filter(p, new $odata.Value(params["CustomerNumber"], _dataTypes["CustomerNumber"]));

I get this error:

odataresources.js:163 Uncaught Cannot convert C068211 into String

I execute the oData.filter in a loop so that I can just loop through the parameters like so:

angular.forEach(params, function(v, p){
   oData.filter(p, new $odata.Value(v, dataTypes[p]));
}

I've worked around this by excluding Strings like so:

angular.forEach(params, function(v, p){
   if(dataTypes[p] != "String") {
      oData.filter(p, new $odata.Value(v, dataTypes[p]));
   } else {
      oData.filter(p, v);
   }
}

But would be best if i can avoid the if else statement.

Best.

@patrickdizon patrickdizon changed the title Cannot convert a certain values to String using $odata.Value("C068332","String") Cannot convert values to String using $odata.Value("C068332","String") Jul 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant