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

"If" type formula

dan-lowry
Deputy Chef I
Deputy Chef I

Hello all!


Is there a way to create a formula that uses .present? on a string and then inserts one of two options into the field? Seems like there is a way to do it, but I'm having issues with the syntax. The specific use case is as follows:

[datapill1].present?

{"true": [datapill1].gsub(_([datapill1]).split(';').first()+"; ","")}

{"false": nil}

6 REPLIES 6

ajorde
Deputy Chef I
Deputy Chef I

[datapill1].present? ? ([datapill1].gsub(_([datapill1]).split(';').first()+"; ","")) : null


Sometimes I want the result to be an empty string instead of nil - in that case, I do this:

[[datapill1],''].compact[0]

vijay-narsimha
Deputy Chef I
Deputy Chef I

you can use something like this



bala-s
Deputy Chef I
Deputy Chef I

=_('data.logger.3dcdc175.message').present?? (_('data.logger.3dcdc175.message').gsub("dr","").split(";").first() + "; " + "") : nil



dan-lowry
Deputy Chef I
Deputy Chef I

Thanks for all the responses! I knew I was missing something and that second ? fixed it.