Button saves the same record and creates duplicate.

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

I have two forms and tables(New Deliveries Summary and SA-M 1013) with general information on them regarding aircraft (Registration#, Line #, Serial #).  New Deliveries is the master reference sheet where I've inputted that general data, while SA-M 1013 has additional details. I've created a relationship between them with a ForumulaURL button in New Deliveries Table which I click and auto populates SA-M 1013 with the general information (Registration #, Line #, Serial Number).  I am able to save form SA-M 1013, and the record appears on the table.   

Now I 'm on the the New Deliveries Table and wish to edit the respective SA-M 1013 so I click the button, add the date, hit save, and it creates a new entry rather than editing the original entry. Is there a way to make the button edit the original first entry rather than create a new one?

Photo of PAUL

PAUL

  • 102 Points 100 badge 2x thumb

Posted 3 years ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,542 Points 50k badge 2x thumb
Let's start with a simple solution as this may be all you need.

While you did not post the formula for the button, I am assuming that it was the Generic Add Child Record button that the system created for you when you made the Relationship.

The system also would have created a report Link field on the left side of that Relationship, probably called SA-M 1013.  if you put that one the parent main form New Deliveries.  Then, in form properties set that field to show the child records directly on the form and setup a rpeort to use for that purpose on that field.  Then when you look at any New Delivery record you will see the aircraft and all its details and can edit any of those detail records.
Photo of PAUL

PAUL

  • 102 Points 100 badge 2x thumb
Well I'm one step closer to the solution but not quite there yet. Maybe I didnt understand your answer correctly. 

I've been able to create a button with New 1013 and a button for Edit 1013. The new button creates a new 1013 for a particular registration(5654), the edit can edit a 1013 for that same registration(5654).  The edit button is a report link like you mentioned which ties the registration numbers on the New Deliveries Table to the SA-M 1013 table. 

The only issue I have is that I can still create multiple 1013's for the same registration.  Is there a way to hide or prevent creating a new 1013 for a registration if there is already one built?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,542 Points 50k badge 2x thumb
On the Relationships where 1 New Delivery has many SA-M 1013's, do a summary count of the # of SA-Ms

Then in the button that you nhave now to ADD a SA-M 1013, wrap it like this

IF([# of SA-M 1013]=0,

urlroot() "db/" etc .........  )

The button will be blank if there is aleady a child record.
Photo of PAUL

PAUL

  • 102 Points 100 badge 2x thumb
Yay!  Thank you that solved the issue! Appreciate all the help.
Photo of PAUL

PAUL

  • 102 Points 100 badge 2x thumb
Just thought of something. Would I be able to build into that formula If function the ability to,
IF([# of SA-M 1013]=0, Create New Record, Edit Existing Record).  This way I would only need one button to create or edit.
The current formula I have can create a new record but when I try to edit an existing record I get an error that the SA-M 1013 does not exist.  Below is my formula.

If([# of 1013s]=0, URLRoot() & "db/" & [_DBID_SA_M_1016] & "?a=API_GenAddRecordForm&_fid_96=" & URLEncode ([Record ID#])& "&z=" & Rurl(), URLRoot() & "db/" & [_DBID_SA_M_1016] &"?a=er&rid="&[Record ID#]&"&dfid=96")
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,542 Points 50k badge 2x thumb
if you create a summary field on the relationship called [Maximum Record ID# of SA-M 1013 records], then edit your formal to edit the correct record id


If([# of 1013s]=0,
 URLRoot() & "db/" & [_DBID_SA_M_1016] & "?a=API_GenAddRecordForm&_fid_96=" & URLEncode ([Record ID#])& "&z=" & Rurl(),
  URLRoot() & "db/" & [_DBID_SA_M_1016] &"?a=er&rid=" & [Maximum Record ID# of SA-M 1013 records])
Photo of PAUL

PAUL

  • 102 Points 100 badge 2x thumb
You are amazing. Thank you! This really has helped out immensely.