The script that you outline should work perfectly whether or not you put the 1 in quotes.
I would guess that the problem lies in the details of:
when I click on an item it sets a field called "selected" to "1".
If you are clicking a check box formatted field to make this selection, it is possible that your check box format is causing the value 1 to be appended to data already in the field instead of replacing it.
I will also note that additional issues may arise if this is a database where several users might be performing this task at the same time as you will each be able to see (and modify) the selections made by others. Thus you might click a check box field to select the record and another user sees a selection that they don't want and they clear it--thus keeping your scripted find from working as expected.
I'm not using a checkbox formatted field. Just a Text Box.
In my picker window, I'm using a portal to show equipment and merged fields to display the item information. I made a button that overlays the information and when I click on the item it fires a script that sets the "selected" field.
The script is simply:
If [Equipment::selected = 0]
Set Field [Equipment::selected; 1]
Set Field [Equipment::selected; 0]
I have another button on my PickerWindow that completes the order and fires my problematic script.
No multiple users, either. Just me.
Just to rule out other possible issues, run a recover on your file and then test the recovered copy (even if it reports no problems found) and see if you get the same result.
What you show is quite simple and should work perfectly.
I might have figured it out.
I took away the new window step. Perhaps I could have added a commit records at the initial start, but it seems to be happy now so I'm going to leave it be...
Yes, I think commit records before entering find mode and before opening a new window would be all that you needed here.