Presumably this is a script that is triggered say OnObjectSave? If that is the case, then the current field will be the field you want the script to operate on so there is no need to even specify a script parameter - you can use Get ( ActiveFieldContents ) in your initial If statement.
In your script, just use the Clear script step without specifying a field (as you have done with Set Field).
The Go to Field script step is not required.
So your script looks like:
If [ Length ( Get ( ActiveFieldContents ) ) ≠ 10 and not IsEmpty ( Get ( ActiveFieldContents ) ) ]
Show Custom Dialog [ Title: "Error"; Message: "Enter ten digits, no spaces or symbols."; Buttons: “OK” ]
Clear [ Select ]
Exit Script [ Result: 0 ]
Else If [ IsEmpty ( Get ( ActiveFieldContents ) ) ]
Set Field [ "(" & Left ( Get ( ActiveFieldContents ) ; 3 ) & ")" & Middle ( Get ( ActiveFieldContents ) ; 4 ; 3 ) & "-" & Middle ( Get ( ActiveFieldContents ) ; 7 ; 4 ) ]
The Exit Script with a false result is added to negate the action (of exiting the field) so the user remains in the field.
I am not sure that you should be clearing the field and making the user enter the whole number again - I would delete the Clear step.
Try the following:
- In layout mode select the field Vendors::Phone, then select Menu - View - Object Info.
In the Object Info type a name for the field, ex: "phone_vendors".
- In your script replace the Clear line with Set Field [Vendors::Phone; ""]
- replace the Go to Field instruction with:- Go to Object [phone_vendors]
This must sort you out.