Select to view content in your preferred language

Writing expressions Arcade where the return is a value from a field

698
3
Jump to solution
05-04-2023 10:45 AM
Labels (1)
JGVadnais1
New Contributor III

Hello!

I've seen many arcade examples where the return is a string or number.  How would one write an expression for the return to be the value from a field?  For example, one of the questions in my survey incorporates rules.  If option 1 is selected then question 3 shows.  If option 2 is selected, then question 4 shows. How would I write the expression where the pop-up display mimics the rule?  I've dabbled in some coding, but this is my first time delving into Arcade.  The documentation is helpful, however, I'm not seeing the answer to my question.

Thank you!!

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

You can access field values by using the field name in brackets or in dot notation:

return $feature["Field"]
return $feature.Field

 

So you could do something like this:

return When(
    $feature.Option1 == 1, $feature.Question3,
    $feature.Option2 == 1, $feature.Question4,
    "something went wrong: both options were deselected"
)

Have a great day!
Johannes

View solution in original post

0 Kudos
3 Replies
JohannesLindner
MVP Frequent Contributor

You can access field values by using the field name in brackets or in dot notation:

return $feature["Field"]
return $feature.Field

 

So you could do something like this:

return When(
    $feature.Option1 == 1, $feature.Question3,
    $feature.Option2 == 1, $feature.Question4,
    "something went wrong: both options were deselected"
)

Have a great day!
Johannes
0 Kudos
JGVadnais1
New Contributor III

Thank you!

0 Kudos
JohannesLindner
MVP Frequent Contributor

If that solved your question, please mark the answer as solution, so this question is shown as solved.


Have a great day!
Johannes
0 Kudos