August 29, 20169 yr Newbies Hello. I have two tables: Person and Recruiting Within Person, I have a field Person::Source (which indicates the recruiting event we first met the person) Withing Recruiting, a record is created for each recruiting event. I have the Person::Source field set to run the following script each time I enter a new Person record, which then creates a new Recruiting record Freeze Window Set Variable [$Source; Value: Person::Source] Go to Layout ["RecruitingList" (Recruiting)] New Record/Request Set Field [Recruiting::Recruiting Event; $Source] Go to Layout [original layout] The problem I am having is that we have several Person records with the same Person::Source value, and each time I run the script is creates duplicate records in Recruiting. Is there anything I can add to the existing script that will prevent the new record from being created if it the record already exists? Edited August 29, 20169 yr by Lee Smith Removed the Red Text
August 29, 20169 yr Sure, after the Go To Layout, do a search first and only create a new record when the Find does not find anything. As an aside: you don't need to use a global variable ($$source) here, a local variable will do: http://www.soliantconsulting.com/blog/2014/02/all-variables-should-be-global-or-not
August 29, 20169 yr I would start by defining the Recruiting Event field to validate as Unique. Then make your script: Freeze Window Set Variable [$Source; Value: Person::Source] Go to Layout ["RecruitingList" (Recruiting)] Set Error Capture [ On ] New Record/Request Set Field [Recruiting::Recruiting Event; $Source] Commit Records/Requests If [ Get ( LastError ) = 504 ] Revert Record/Request [ No dialog ] End If Go to Layout [original layout]
August 29, 20169 yr Author Newbies Hello Comment, This worked perfectly! The Unique validation tip also helped me figure out another issue I was having. Thank you very much!
Create an account or sign in to comment