Switch Function

Hi All,

I’d like to perform a Javascript switch function on the data coming in from a form.

I’ve managed to use:
field(‘Disability__c’, function(state) { return ((dataValue(“disability”)(state)===“yes”)?“true”:“false”)}),

To transform “yes/no” to “true/false”, and to find and replace specific values with the following code:

field(“Race__c”,function(state){

return dataValue(“race”)(state).toString().replace(“african”,“Black”)

Still, my sense is that there must be an easiest way to do this than to simply write an extended find and replace.

Any assistance would be greatly appreciated.

Best,

Kayin

Hey Kayin,

Can you share your whole job expression? I might recommend creating a custom function (or object with props set like {“original”: “new”} at the outset, and then using that function in your later field calls.

We’ve also been thinking about letting users define replacement tables. This sounds like the right case for it.

Taylor