AnsweredAssumed Answered

Scripting with Error 504

Question asked by sfishman@ou.edu on May 19, 2018
Latest reply on May 20, 2018 by sfishman@ou.edu

I need help in scripting to have the database automatically revert a record that is not unique.  I have two tables - project and client that are connected with a linking table.  I have a script that automatically populates new records in the  project table after the clients are chosen in a separate table.  Everything is being transferred with a loop script with copy and pasting - due to the unique non-server multi-user environment. This part of the script works fine.

 

My problem is when the record has already been entered, in this case, resulting in 2 of the same clients for the same project. The unique identifier is a concatenated field (projectId + cliient Id) that, when together, prevents any record from being entered twice. The field is set with a validation to always look for it and provide a personalized error message. 

 

Allow User Abort [On]

Loop

     Freeze Window

     Select Window [Name: "Client"; Current File]

     Go to Record/RequestPage [Next; Exit after last]

     Copy [Select; Client::ClientId]

     Select Window [Name: "Project"; Current File]

     New Record/Request

     Paste [Select; ProjectClientLink::ClientId]

 

#Here is where I need help...

     Set Error Capture [On]

     Commit Record <<I am asking the computer to check for validation errors - which having a duplicate is the only possibility>>

     If[Get(LastError)=504]

          Revert Record/Request [] <<Is this correct?>>

     End If

End Loop

Exit Script[]

 

I am new at the error capture feature in scripting.  It is ignoring my error - but I am still getting the message below for each instance.  Maybe it isn't an error 504?  ... 

I just want it to automatically revert and not bother the user.  Especially when some of the batches are >500 records.

Outcomes