What's the best way to do an if statement for status codes?
What's the best way to do an if statement for status codes. Like is status=400, a new field is made statusCode = "Bad Request"
Answers
-
If a one off, use something like this in an eval statusCode = `status == '400' ? "Bad Request" : statusCode`
0 -
you could have a series of those
0 -
I was thinking maybe a lookup too, since status codes are pretty much static
0 -
Better, more scalable solution IMO is to use a lookup file (under processing, knowledge) statusCode = `C.Lookup('filename.csv','code').match(status,"return_field")`
0 -
you can also use the built-in Lookup function
0 -
AND mind the type of field status is! Is it a number or a string? You'll need to match the type
0 -
Good point, I'll be sure to check on that
0 -
lookup is far easier to maintain than the series of if/or statements.
0