4 Replies Latest reply on Nov 28, 2012 5:52 AM by RonaldCarr

    Replace value in a field - in script



      Replace value in a field - in script


           I am looking for the script step to use to change 0 to No, and 1 to Yes in a field in all records.

           This may take 2 steps which is OK.

           I tried Perform Find/Replace, Set Field by Name, Replace field contents: not quite sure how to use them.

           Also do I do record movement myself or is there a blanket find/replace that would do it for the found set?

           And the question is necessary because Filemaker dos not have a Boolean data type so I assume I need a Yes-No value list for these fields...correct?

           Thanks! Haven't used Filemaker in a number of years...

        • 1. Re: Replace value in a field - in script

               I don't think you need to change the value of the field at all. Use a field of type number for boolean fields. Using data formatting from the inspector's data tab, you can then specify that values of 1 be displayed as "yes" and values of 0 as "no".

          • 2. Re: Replace value in a field - in script

                 And the user entering data in that field uses...?

            • 3. Re: Replace value in a field - in script

                   a 1 or a 0, but that can be supplied by a value list or scripted buttons.

                   If you prefer to store the text as yes and no, replace field contents with the calculation option can be used.

                   Put the field on a layout and put the focus on the field by clicking or tabbing into it. If it's formatted with radio buttons or such, click one radio button then the other to keep the value unchanged, but still put the focus in the field.

                   Select Show All Records from the Records Menu

                   Select Replace field contents from the Records menu and select the calcualtion option.

                   Use an expression such as:

                   If ( YourBooleanField  = 1 ; "yes" ; "no" )

                   This assumes that you have a single number, 1 in the field and that you want the value "no" to be entered into the field if 1 is not currently stored in the field.

                   Since this will change the value of this field for every record in the table and cannot be undone, save a back up copy of your file before trying this out.

                   Ps. if your field if of type Number, change it to text after making this change.

              • 4. Re: Replace value in a field - in script

                     OK I was able to make a script using Replace Field Contents with that condition as the Condition, and no "Specify Target Field: that is what was also confusing me.

                     Thank you.