Jump to content
Server Maintenance This Week. ×

Problem with script inserting text into field


This topic is 1321 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have a field named "Databases" with the following values: "CORD", "SDHS", "Y Ballet". This field is displayed as a checkbox set. I recently learned that "CORD" should have been "DSA", so I naively changed "CORD" to "DSA" in the value list but then none of the records that were checked for "CORD" were checked for "DSA", which reminded me that the values in the value list are the values of the field Databases and not labels for checkboxes. I revised the value list to again include "CORD" and its checkbox is again checked for all the records for which it was originally checked.

I wrote a script, shown in one of the attachments, to insert "DSA" into the Databases field for each of the records that contains "CORD" in that field. When I run the script I get an error message saying "Databases" is defined to contain only specific values, and that I must enter a valid value. How can DSA not be a valid value when it is included in the value list for the field? How can I accomplish what I want to do?

Does programming scripts in FileMaker ever get easier? I don't write many scripts, but when I do I find it surprisingly difficult to accomplish what I think would be the simplest of tasks.

Thanks in advance for your help,

John Link

22598958_ValueList.png.515a59af957824c887db34e702700efe.pngScript.png.76a03749ce450b437e1e31c5a920294a.png22598958_ValueList.png.515a59af957824c887db34e702700efe.png361709511_Errormessage.png.fc0449bafc580c9f7d9598b942fb2673.png

Edited by John Link
Link to comment
Share on other sites

If you want to know what's really happening, place another instance of the field on the layout and format it as an edit box. Then you will see that if the field has say CORD and SDHS checked, it contains:

CORD
SDHS 

Now, your script inserts the text "DSA" at the default insertion point, which is at the end of the field's data, resulting in:

CORD
SDHSDSA

and "SDHSDSA" is not in your value list.

 

Based on your description, I would expect to see an entirely different action:

Set Field [ YourTable::Databases; Substitute ( YourTable::Databases ; "CORD" ; "DSA" ) ]

 

Note also that your script is missing a Loop section. it will modify the first record (or at least try), move to the next record and stop.

 

Edited by comment
Link to comment
Share on other sites

This topic is 1321 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.