I have a form that looks for responses to about 30 questions. Each question has a yes/no toggle. When the toggle is 'no' a drop-down appears (and is required) for the user to select 1, 2 or 3. This is controlled by a rule, with one rule for each question.
I am looking to capture the highest score applied as the user proceeds through the form. I have created a form variable (integer) and set '0' as the default value.
What I'd like to do is convert the selected score to a number, then test if it is > the value of the running score. If that test is true, then I set the running score to that value. If it is false, then the running score remains at the highest score previously logged. I can't find a way within the rule to adjust the value of my running score - am I missing something?
Would be grateful for any suggestions, I'd like this cumulative score to be visible to the user before the form is submitted.
Solved! Go to Solution.
Just to clarify if a user inputs 1 on the first choice you want the running score to be 1. Then if the user inputs 2 on the second choice you want the running score to be 2 correct? because 2 >1. And so on and so forth if the user selects 3 for an answer on a subsequent choice control.
Well, you could create a form variable with a formula like this:
max(convertToNumber([Form].[Choice single 1]),convertToNumber([Form].[Choice single 2]),convertToNumber([Form].[Choice single 3]))
Unfortunatly you cannot bind a form-variable to a field in the form, so the computed value will not be visible in the form, but it is available in the workflow.
Thanks for that, eiben - I now realise that I cannot do what I want. I was very much looking to have the result visible as the form is being completed, because it's a form to record observation of a safety procedure, and both the observer and the observed party are expected to sign indicating agreement. The exercise may take place in a location without network connectivity, so a workflow wouldn't execute until the observer returns to a location from where the form will be submitted.
I defined a variable exactly as you suggested but got stuck when I tried to set a rule for each question that would compare the score for that question with the running score variable and update a 'Maximum Score' field with the then-current value of the variable.
I'll have to re-think the approach with the stakeholders.
The response, however is very much appreciated!
Solution identified after some discussion with a Nintex field support rep:
1. Define a field 'RunningScore' or similar and set initial value to 0.
2. For every individual score collected on the form, define a rule that tests the value of the selected score, and set 'RunningScore' to the value being tested. In other words
If [Score] = 1, then [RunningScore] value is 1.
2. Repeat to find scores of '2 - the first one encountered will set the value of RunningScore to 2.
3. Repeat for score values 3 through n.
It's not especially elegant but it works.
An alternative solution has been identified - Kudos to Jake Dennison at Nintex UK, who took the time to think this up and test it. It's preferable to the preceding solution as it's simpler and scales better.
The question fields remain (in my case) as a selection of 1, 2 or 3 from a drop-down, so each question has a 'score' value which is a single-line text field In the form
Create a text variable to combine the answers to all of the score fields as a string (for example, fields Score1, Score2, etc.:
Define varCombine as [Form.Score1]+[Form.Score2] and so on.
If all score fields are 1, for example, then varCombine will be "1 1 ..."
If Score1 is 2 and Score2 is 1, then varCombine will be "2 1 ..."
To test for the highest score, create a second variable that uses the following logic:
If varCombine contains 3 then 3, Else If varCombine contains 2 then 2, Else If varCombine contains 1 then 1, Else 0.
Define varResult as:
The value of varResult can then be displayed on the form by assiging it to a label (to overcome the limitation that prevents a variable from being bound to a field).