AnsweredAssumed Answered

Create/Edit Layout + Script

Question asked by KenHoopes on Aug 31, 2015
Latest reply on Sep 2, 2015 by erolst

Hey All,

 

I'm looking for help with some scripting for a "create/edit" layout that will serve a dual purpose. This layout has three global fields on it, and it can be accessed via two different ways. The first way, is by clicking a "create new drawing revision" button. When accessed this way, the "create/edit" layout, with it's global fields, loads blank. The second way is by selecting a revision that already exists, on a separate lookup drawings layout, by clicking a "edit drawing revision" button. When access this way, the "create/edit" layout, with it's global fields, loads prepopulated with the information from the selected record in the previous "lookup drawings" layout.

 

What I need it to do now, is run a script attached to a button that is intelligent enough to check against multiple fields if a record already exists, and if it does not, to create a new record, and if it does, then to simply edit the old one.

 

(Note: This is not the actual database design, I'm just using this as an example to assist me in my actual database.)

 

 

Show Custom Dialog [ Title: "Confirmation"; Message: "Are you sure you wish to create/edit this setup sheet record?"; Default Button: “Yes” ,

Commit: “No”; Button 2: “No”, Commit: “No” ]

If [ Get ( LastMessageChoice ) = 2 ]

Halt Script

End If

If [ gtbl_dwgs::drawing = "" or gtbl_dwgs::rev = "" ]

Show Custom Dialog [ Title: "Empty Fields"; Message: "All fields marked as required must be completed."; Default Button: “OK”,

Commit: “No” ]

Halt Script

End If

Go to Layout [ “tbl_dwgs” (tbl_dwgs) ]

Enter Find Mode [ ]

[ Pause ]

Set Field [ tbl_dwgs::drawing ; gtbl_dwgs::drawing ]

Set Field [ tbl_dwgs::rev ; gtbl_dwgs::rev ]

Set Error Capture [ On ]

If [ Get ( FoundCount ) = 0 ]

New Record/Request

Set Field [ tbl_dwgs::drawing ; gtbl_dwgs::drawing ]

Set Field [ tbl_dwgs::rev ; gtbl_dwgs::rev ]

Set Field [ tbl_dwgs::notes ; gtbl_dwg::notes ]

End If

If [ Get ( FoundCount ) > 0 ]

---I am sort of lost here as to what to put---

End If

 

That is where I get stuck. Additionally, I am not sure if I am correctly checking the table for multiple fields. Simply already having the drawing number is not enough, it needs to check if it has the drawing number, and the revision. Please advise on that as well.

Outcomes