cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Error calculating input for field 'fieldName': no implicit conversion of nil into String

snm
Deputy Chef II
Deputy Chef II

I'm troubleshooting a job failure with the error: Error calculating input for field 'fieldName': no implicit conversion of nil into String.
I understand that the likely cause of this error is due to a + operation trying to act on a nil value from the input data. And the use of .present? or .presence could help mitigate the problem. But I am not sure how to factor that into the formula:

snm_0-1703778263924.png

Any help or guidance would really be appreciated. Thank you!

 

2 ACCEPTED SOLUTIONS

gary1
Executive Chef III
Executive Chef III

The error message you provided doesn't appear to pertain to the screenshot/formula. "fieldName" is not present in the formula. I'm guessing that the output of "Business Unit Ref ID" is being added in "fieldName" elsewhere. What does that formula look like?

In your response above to dcornwell, you mention a new error: "Error calculating input for field 'BusinessUnitRefID': no method 'where' for true". This is interesting because it appears that the value for "Custom fields" is expected to be an array of objects, but is arriving as a boolean (and you can't .where a boolean).

Without knowing more, I could only classify this as "very odd" and I recommend looking at the input data first. If the input data is arriving in an unexpected format, that may be the root cause of the formula backfiring. Once you confirm the input data is correct, read on for a suggestion on fixing the issue.

When any of the where methods return no results, you'll hit an error. This is because the other methods used to transform the result (upcase, '+', split, gsub) are string methods that will not work on nil data types. 

If you really want to retain the formula as is without rewriting it into a Ruby snippet or multiple actions, I recommend first checking for the value before transforming it like this:

 

 

## test to see if a result is present without transforming
(([Custom Fields].where("Name": "xxx").pluck('Value').first.present? : 

## now transform and test each case in a callback hell of nested ternary operators

   (([Custom Fields].where("Name": "xxx").pluck('Value').first.upcase.include?("xxx") ? 
   "result when true" : 

      ## next ternary operator here
      {test condition} ? {true result} : 

         ## next ternary operator here
         {test condition} ? {true result} : 
   
   ## ... and so on until the end of time

 

Edit: I should also mention that if the .where("Name": "xxx") is always testing for the same name "xxx", you can check for presence once at the beginning of the formula. However, if the formula checks for multiple names throughout the formula (I can't tell, they are blurred), then you'll need to test for presence each time (for each name) at the start of a new nested ternary operator. I'm getting dizzy just thinking about it!

View solution in original post

marlon-muela
Workato employee
Workato employee

Hi @snm ,

One possible reason you are getting an error is that the data pill used has an empty value.

The error indicates that it was unable to move forward with the conversion/formula is because the value is empty of doesn't match the data type being used in the formula.

Check if step 3 has a value on the job output. One suggestion for troubleshooting is to try using a static value to see if the error reproduces.

View solution in original post

6 REPLIES 6

marlon-muela
Workato employee
Workato employee

Hi @snm ,

One possible reason you are getting an error is that the data pill used has an empty value.

The error indicates that it was unable to move forward with the conversion/formula is because the value is empty of doesn't match the data type being used in the formula.

Check if step 3 has a value on the job output. One suggestion for troubleshooting is to try using a static value to see if the error reproduces.

Hi @marlon-muela,

Thank you for your response and apologies for not reverting back on this thread sooner. Yes, ultimately the issue was found to be a null value being returned from the lookup table due to a match not existing. This was causing the string concatenation to throw an error and fail the job.

Big thanks to you, @gary1 and @dcornwell for all your time and assistance!