Definitely something doesn't make sense with your script.
What layout are you on when the script is performed? If You open up layout setup... for that layout (enter layout mode first), what is shown in "Show Records From"? does it show "Contact Management".
What is puzzling is that your script copies text from "Contact Management::sw_First_Last" into a variable named $NewCallerFL. Then it closes a window, selects another window that appears to be open to a layout also based on "Contact Management", (But can't tell if that's really the case) and then performs a find for a record in Contact Management with the same exact text in the very same table and field: Contact Management::sw_First_Last. This would appear to pull up the same record in this window as was current in the original window "NewCallStart".
So far so good, but then things fall apart if the Error Code 401 is returned. This could only happen if the find failed to find any records but I don't see how that code could possibly be returned here. If no first/last name was entered, error code 400 (missing criteria) should be returned. But if the field is not empty, then it should find a record, the record that was current in the "NewCallStart" window when the script was performed.
So I don't quite see how the steps inside the IF block could possibly be performed and if they where wouldn't the variable $NewCallerFL be empty?
If you have FileMaker Advanced, I'd enable the script debugger, open the data viewer and then step through the script watching windows open/close and layouts change as the script executes to see where exactly this script goes wrong and that should then help you figure out how to change it.
There is a layout called CallsList. On that layout is a button called New Caller. When you click that button it brings up a small window called NewCallStart with a field to type in a name. As you start typing it will match up automatically with any name already in the database. If you end up choosing an item from the database and click on the Add Call button, everything works fine. The issue is when it doesn't match. From what I can tell, the script tries to add an entry if it doesn't find a matching entry, but I don't think that's working.
I do not have the Advanced version unfortunately.
Does what I said here help clarify anything?
Oh, I forgot to mention that the script screenshot above is the one that runs when you click the Add Call button. Should I be looking elsewhere?
It helps a bit, I see design issues with the method you describe when I compare that description to the script. If the user "chooses an item from the database", that should select an ID number for that contact record, not just copy over the first and last names. Names are not unique, the name for a given person can take more than one form and are vulnerable to data entry errors--all of which can create problems for the method implemented here in the script. That has nothing to do directly with the problem that you are having, but it's something to keep in mind for the future.
The only find performed in the script first uses Set Error Capture[on] to surpress any error messages generated by performing the find. Thus, I am puzzled has to how that message pops up.
And the whole "create a new record if no contact is found" part of this process is problematic. The first line of the script:
Set Variable [$NewCallerFL ; value: Contact Management::sw_First_Last ]
Copies a value from the field in Blue.
Then, in the portion of the script that performs a find, you have:
Set Field [ Contact Management::sw_First_Last ; $NewCallerFL ]
The only way that this could possibly fail to find a record would be if the record in the original window was not committed and since you are closing the window it sould seem that this data has to be committed at this point. (as a test, I opened a new window, edited a record and then closed the window. As expected, the data was automatically committed when the window was closed.
And thus, I see no way that the portion of the script that creates a new record could ever execute.
Since you don't have Advanced (It's worth the added cost to upgrade, the tools in it can save you hours of trying to debug issues with your scripts.), you can insert a series of show custom dialog steps in this script--each with a different message that also displays key data from your fields and variables, then run the script and see which dialogs pop up before you get that error message.
It would be hard to recommend purchasing the advanced version to a client just to troubleshoot this one issue. Generally, I'm not involved with this kind of thing at all and may have to back out of helping with this as it is. I had been hoping it might be something easy. Of course, it might be that I'm looking in the wrong place entirely for the problem.
Regardless, thanks for the help! I really appreciate it.
It would be hard to recommend purchasing the advanced version to a client just to troubleshoot this one issue.
I would not do that either. I'd get that copy for myself so that I could trouble shoot that issue as well as to benefit from the other valuable and useful tools that it provides the developer.