Forum Discussion

FrancescoSpiga1's avatar
FrancescoSpiga1
Qrew Cadet
6 years ago

Save and keep working + trigger an API on same record (Edit Record)

I am trying to combine the below code (copied from previous conversations) with an API_EditRecord 

"<div class='Vibrant Success' onclick=$('#footerSaveAndKeepWorkingMenuOption').click();>SAVE AND KEEP WORKING</div>"

I need to:

1) Save the record (the above code will do it) 
2) Trigger an API that will edit the record I just saved

Can this be done with one button click?
Will this work on the mobile APP?

Any help will be greatly appreciated. 



  • AustinK's avatar
    AustinK
    Qrew Commander
    What do you mean by "trigger an API that will edit the record"? What are you trying to do when you edit the record? Can an automation work for you? It could fire when a record is saved or other types of triggers and do pretty much whatever you want with the record.
  • Check out the magic buttons app in the exchange:

    https://magna-5325.quickbase.com/db/main?a=AppDetail&ID=2660&app_name=Magic%20Buttons%20-%20Having%20fun%20with%20formula%20...

    There are many examples of using the API to edit records. Here is an example of editing a record after a prior action from the Magic Buttons app; Check/Uncheck a checkbox then edit record:

    If([Checkbox] = false,
        "<a class='Vibrant Primary' style=\"width:310px; text-align: center;\" href='" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&apptoken=d9eascudwjxs2sesxkjccwgtq9r&_fid_101=1&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=er&rid=" & [Record ID#]) & "'>5B. Check a checkbox then edit record</a>",
        "<a class='Vibrant Primary' style=\"width:310px; text-align: center;\" href='" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&apptoken=d9eascudwjxs2sesxkjccwgtq9r&_fid_101=0&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=er&rid=" & [Record ID#]) & "'>5B. Uncheck a checkbox then edit record</a>"
    )

    // Press the button and this changes the "Checkbox" to checked and returns to edit record mode
    // Press it again and this changes the "Checkbox" to unchecked and returns to edit record mode
    // In this variation you can actually change the button label for each and it will reflect in the button

  • AustinK, that would work but then I'll have to refresh the page to see the updated record - the automation lags compared to APIs (not a big deal anyway, this could work)

    Adam Keever, Thanks for the suggestion. I'll check out the magic buttons and see if I can make it work the way I want. 

    My problem is that the record has not been saved yet... I want to save the record and then trigger the API or automation and display the updated record... 
  • Depending on the specifics of what you want to accomplish, you may be able to use the Save&Keep Working native button and use a dynamic form rule to change a field when the date created field is no longer blank.

    I used this technique to hide a section of a form until the record was created, then once the record has a date created, then a dynamic form rule shows the additional sections. The bad part was that after save, the form opens in edit back at the top of the form, so I added a button at the top of the form to jump back down to the end of the section they just finished.
  • I still have the issue of saving the records once the form rule gets triggered.
    I am going with the automation for right now... I'll keep messing with the rich text field... I'll post something If I can get it right.
  • For the records, I ended up using the below:

    var text url = "javascript:DoSaveAdd()";
    "javascript:" & "$.get('" & $url & "',function(){" & "location.reload();" & "});" & "void(0);"

    1. I change one of the fields with a form rule (Status = NEW to PENDING)
    2. I post a child record with automation (who submitted the request and when)
    3. Page refreshes and shows the child record (JS location.reload)

    Table Advance Settings -
    Make sure to check the option : "Save parent record automatically when a child record is created."

    one click. mission accomplished! 
    Thank Adam!
    • AdamKeever1's avatar
      AdamKeever1
      Qrew Commander
      Congratulations! Way to stick with it and thanks for posting your final solution Francesco.