1 Reply Latest reply on Aug 22, 2012 10:36 AM by philmodjunk

    Set Checkbox using a script



      Set Checkbox using a script


      This may be a no brainer, but I need help with setting a checkbox using a script.

      I am duplicating a record that has a few fields with checkboxes and during this duplication I want one of these checkbox fields to automatically have a check in it for the new record. Hope this makes sense..

      Any help would be great!



        • 1. Re: Set Checkbox using a script

          IF you want one and only one check box selected in the field. Use Set Field to set the value for that check box just as though this were a simple text field.

          If you need to select more than one check box or you need to add that selection without losing the data already selected, you'll need to use a more sophisticated expression.

          This script step selects "new Record" while not losing any other values already selected in the field:

          Set Field [yourTable::yourcheckboxField ; List ( YourTable::YourCheckboxField ; "New Record" ) ]

          If there's a chance that "new record" might already be selected, you can keep the data in this field a bit cleaner (you won't see any difference unless you inspect the field without any check box formatting):

          Set Field [ YourTable::yourcheckboxField ; If ( IsEmpty ( FilterValues ( YourTable::YourCheckboxField ; "New Record" ) ) ;
                                                                                            List ( YourTable::YourCheckboxField ; "New Record" ) ;
                                                                                            YourTable::YourCheckboxField) ]

          This expression avoids appending a second instance "new value" if it is already selected.