Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added Rule to capture logged in username and email.

...

Code Block
languagejs
titleCalculated Value Script
linenumberstrue
//Add state control to checkboxes to mimic radio button behavior.
if(data.check1 === true  && (data.checkState == '2' || data.checkState == '3'))
    {
        value = '1';
        data.check2 = false;
        data.check3 = false;
    }
else if (data.check2 === true && (data.checkState == '1' || data.checkState == '3'))
{
    value = '2';
    data.check1 = false;
    data.check3 = false;
}
else if (data.check3 === true && (data.checkState == '1' || data.checkState == '2'))
{
    value = '3';
    data.check1 = false;
    data.check2 = false;
}
else if (data.check1 === true)
    value = '1';
else if (data.check2 === true)
    value = '2';
else if (data.check3 === true)
    value = '3';
else
    value = '';

Populate Username or Email Address of Logged in User

You can populate the Name or Email Address of a logged in user by placing the below code in the Calculated Value Rule area on the Data Tab.

Code Block
languagejs
titleCalculated Value Script
linenumberstrue
//Capture the email of the current logged in user into the value of the selected control
value = Formio.getUser().data.email


//Capture the name of the current logged in user into the value of the selected control
value = Formio.getUser().data.name

You can couple this rule with an if statement in a workflow to ensure it only fires once and does not overwrite the name/email if the form is loaded in additional workflow steps.