Forum Discussion

KellyBianchi's avatar
KellyBianchi
Qrew Assistant Captain
5 years ago

api add a record if one does not exist

I am able to write the formula to add a record, but I get an error page if the record already exists. How can I add the ability to only add if the record does not exist?

If([Auction]="Dealers", URLRoot() & "db/bn52z25bj" & "?a=API_AddRecord&apptoken=xxxxxxxxxx&_fid_39=" & [AMS#]& "&_fid_6=" & [Dealership Name] & "&_fid_17=" & [Tel:])

------------------------------
Kelly
------------------------------
  • I don't know enough from you post to understand the your app and it's relationships, so here are a couple of thoughts.

    If you are trying to create a parent record by launching off the Child, my suggestion is to create a field on the Parent table called [AMS Exists?] (if that is the Parent table) as a formula checkbox field with a formula of
    true. The look that up down to the child table and build that into your formula so that the button goes blank if there is already a parent AMS# loaded.

    If([Auction]="Dealers" and not [AMS# Exists?], URLRoot() & "db/bn52z25bj" & "?a=API_AddRecord&apptoken=xxxxxxxxxx&_fid_39=" & [AMS#]& "&_fid_6=" & [Dealership Name] & "&_fid_17=" & [Tel:])


    But then the other problem is that when you button runs it will spew back on the screen the XML success message which is not user friendly.

    If you tell me where you want the screen to refresh to after the button is clicked I can help you with that.  Do you just want to refresh the record or are you launching off a report?

    .


    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------
    • KellyBianchi's avatar
      KellyBianchi
      Qrew Assistant Captain

      This is actually to create a record in another table. Perhaps it would be easier to have a combined edit or add option, because I would like the record to be updated. Would that solve the problem? Can you provide the code for that?





      ------Original Message------

      I don't know enough from you post to understand the your app and it's relationships, so here are a couple of thoughts.

      If you are trying to create a parent record by launching off the Child, my suggestion is to create a field on the Parent table called [AMS Exists?] (if that is the Parent table) as a formula checkbox field with a formula of
      true. The look that up down to the child table and build that into your formula so that the button goes blank if there is already a parent AMS# loaded.

      If([Auction]="Dealers" and not [AMS# Exists?], URLRoot() & "db/bn52z25bj" & "?a=API_AddRecord&apptoken=xxxxxxxxxx&_fid_39=" & [AMS#]& "&_fid_6=" & [Dealership Name] & "&_fid_17=" & [Tel:])


      But then the other problem is that when you button runs it will spew back on the screen the XML success message which is not user friendly.

      If you tell me where you want the screen to refresh to after the button is clicked I can help you with that.  Do you just want to refresh the record or are you launching off a report?

      .


      ------------------------------
      Mark Shnier (YQC)
      Quick Base Solution Provider
      Your Quick Base Coach
      http://QuickBaseCoach.com
      mark.shnier@gmail.com
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend
        Yes, I understand that this is to create a record in another table.  Is there a relationship between the tables?  Can this record "know" if the other record to be created or edited exists?  Can you tell me the Key field of the other table?

        ------------------------------
        Mark Shnier (YQC)
        Quick Base Solution Provider
        Your Quick Base Coach
        http://QuickBaseCoach.com
        mark.shnier@gmail.com
        ------------------------------