Formula mode error when 'adding' data pills together using '+'
Hi, I was using a formula like this (data1 + data2 + data3) when I encountered some error messages..
Error messages:
1. No implicit conversion of nil into string error
2. Formula received a nil value: undefined method `+' for nil:NilClass
I received the errors on different jobs. One of them had null value in description, the other had null value in amount. I thought that if a data pill was empty/null, then the empty pill would be passed.
Best Answer
C
Chandra Vippena
said
over 7 years ago
Hi Saul,
While using + operation on data pills, If any of the data pill expecting to be empty or nil, It should be handled explicitly by using present? or presence.
Always, when using + with data pills for concatenation, it is a method call. so It tries to evaluate data pills and then concatenate. You have to make sure that pills on both ends should not be nil or empty.
Answer
C
Chandra Vippena
said
over 7 years ago
Hi Saul,
While using + operation on data pills, If any of the data pill expecting to be empty or nil, It should be handled explicitly by using present? or presence.
Always, when using + with data pills for concatenation, it is a method call. so It tries to evaluate data pills and then concatenate. You have to make sure that pills on both ends should not be nil or empty.
Amanda Wong
said
over 7 years ago
You can also refer to this solution article on how to use .present? to handle such errors
Saul Macht
Formula mode error when 'adding' data pills together using '+'
Hi, I was using a formula like this (data1 + data2 + data3) when I encountered some error messages..
Error messages:
1. No implicit conversion of nil into string error
2. Formula received a nil value: undefined method `+' for nil:NilClass
I received the errors on different jobs. One of them had null value in description, the other had null value in amount. I thought that if a data pill was empty/null, then the empty pill would be passed.
Hi Saul,
While using + operation on data pills, If any of the data pill expecting to be empty or nil, It should be handled explicitly by using present? or presence.
Always, when using + with data pills for concatenation, it is a method call. so It tries to evaluate data pills and then concatenate. You have to make sure that pills on both ends should not be nil or empty.
Chandra Vippena
Hi Saul,
While using + operation on data pills, If any of the data pill expecting to be empty or nil, It should be handled explicitly by using present? or presence.
Always, when using + with data pills for concatenation, it is a method call. so It tries to evaluate data pills and then concatenate. You have to make sure that pills on both ends should not be nil or empty.
Amanda Wong
You can also refer to this solution article on how to use .present? to handle such errors