I want to make an automation to look at the checked values on a checkbox field and assign them a numerical value and then sum them. Then I want to use that sum to set another field. I've tried a number of things to no avail. The real difficulty I'm having is determining what items are selected in the checkbox.
Hi @iotim
For a question like this, context is important for the community to help. Please post the following:
Until we see those...
Whether using multiple, built-in checkbox fields or values in a checkbox field app, you could try using a conditional, smart value expression to test the values and add the number values using a math expression.
If instead, your checkbox values contain the numbers to add in the text, it might be possible to extract them for addition from the selected options.
Kind regards,
Bill
I'm using the built-in checkbox field. My automation is an incomplete mess of tests currently. I'm stuck trying to get the first part to work so I haven't moved on. Here are some things I've tried:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for that information, @iotim as it indicates some things to try...
First, when accessing a checkbox field's values, that is a list of values...not a single value. The expression you show might produce a list of true / false values, and thus not work as expected.
Next thing, if the contains() function actually works with text, it is undocumented. I recommend not using those as they can change without notice. Instead, we may use the match() function and a list size check.
Putting those together, your first condition test could be this instead:
{{#if(issue.customfield_10060.value.match("(Recurring\/Solve Many Issues\?)").size.gt(0))}}+ 5{{/}}
That works by counting the matches for that text with the size function, and testing if the result is greater than 0. Please adjust the regular expression as I was guessing at your exact text...and note the extra parentheses added to make the match work.
If you do not want to use regex, you could also use indexOf() and test for a value greater than -1. For this approach, the list of values needs to first be joined into a single text string.
{{#if(issue.customfield_10060.value.join(",").IndexOf("Recurring/Solve Many Issues?").gt(-1))}}+ 5{{/}}
And as you saw, branching / looping will not work for this scenario (due to asynchronous processing).
There is a more complicated way to solve this by first storing the mapping of values-to-numbers in a Lookup Table, but that would involve some complicated string handling...and it might be too much for this scenario.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.