Can you create a save button with an API call?

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • In Progress
  • (Edited)
I have put together the following api call

URLRoot() & "db/" & [_DBID_ACTIVITY_LOG] & "?a=API_GenAddRecordForm&_fid_11=" & "Tasked to Team Member:        " & URLEncode ([Description]) & "&_fid_50=" &URLEncode([Company Name (ref)]) & "&_fid_47=" &URLEncode([Worker or Project Name (ref)]) 

To redirect and pass information, though to use it, you need to save the page first. So for the sake if saving a couple clicks, is there a way to also incorporate a save function, so the user does not have to save before hand?
Photo of Jordan

Jordan

  • 1,574 Points 1k badge 2x thumb

Posted 2 years ago

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

QuickBaseCoach App Dev./Training, Champion

  • 53,570 Points 50k badge 2x thumb
Are you in fact wanting to create a record with API_AddRecord and then either land the user to view that record or else to redirect to somewhere else.

The GenAddRecordForm puts up and add record form. The API for AddRecord actually creates the record.
Photo of Matthew Neil

Matthew Neil

  • 31,478 Points 20k badge 2x thumb
Regardless of the AddRecord or AddGenRecordForm (which your examples shows AddGenRecordForm),

You will want to use the 'LinkAway' function in a formula text field, like so:

"<a  class='Vibrant Success' href='javascript:LinkAway(\""&[URL Formula]&"\");'>Submit and redirect</a>"

// This works because you have turned on the table's advance settings, "Save parent record automatically when a child record is created."
// This also is borrowing the LinkAway that gets automatically added for formula url fields.  We are invoking it here so when we are directed to the success.html page the record is first saved.
Photo of Jordan

Jordan

  • 1,574 Points 1k badge 2x thumb
So in order to do this, I need to create a field for the API call and a separate field for what you have described above?
Photo of Matthew Neil

Matthew Neil

  • 31,478 Points 20k badge 2x thumb
Keep the formula URL field that you have from above (you know if already works), but insert that field into the formula I pasted, replacing [URL Formula].

Then on the table A's advanced settings there is a checkbox:


Make sure that is checked, then the new formula text field will (1) Save the current record and (2) go to your new Form.
Photo of Jordan

Jordan

  • 1,574 Points 1k badge 2x thumb
The original URL Formula seems to be working on its own, and I have that box checked off, though it doesn't not seem to be working 

[Add Activity Formula] = URLRoot() & "db/" & [_DBID_ACTIVITY_LOG] & "?a=API_GenAddRecordForm&_fid_11=" & "Tasked to Team Member:        " & URLEncode ([Description]) & "&_fid_50=" &URLEncode([Company Name (ref)]) & "&_fid_47=" &URLEncode([Worker or Project Name (ref)])

And I`m using:

"<a  class='Vibrant Success' href='javascript:LinkAway(\""&[Add Activity Formula]&"\");'>Save Task and Add Activity</a>".

I`m getting asked I wanted to leave the page and it`s not saving, and it does still redirect me to the correct form, though no information is passed. 

EDIT: 

My mistake, I forgot to enable HTML tags, this did the trick, thank you guys!
(Edited)
Photo of Jordan

Jordan

  • 1,574 Points 1k badge 2x thumb
I am wanting them to be arriving at the form to create a record when they arrive in [_DBID_ACTIVITY_LOG]. They are arriving at the form for creating the record  [_DBID_ACTIVITY_LOG] and all the information is being passed properly. The only issue is, to do this they need to save before clicking the button. So they fill in the form in Table A, click save, then click the button to invoke the api call, and arrive a the form in Table B with all the information passed. I would like to combine the save and api call into one button.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 53,570 Points 50k badge 2x thumb
Ok, so you are using the wrong API. Use API_AddRecord and include the suffix &disprec=1


This will land the used in the newly created and saved record.

Or in fact do you want to simply refresh the record where they started from. I'm not sure where you want to land the user after they create the new record.
(Edited)
Photo of Jordan

Jordan

  • 1,574 Points 1k badge 2x thumb
I'll describe the scenario to see if it provides more clarity. A user wants to create a Task in Table A, fills in the form, clicks save. They now want to create an Activity in Table B related to the Task in Table A. On the Task record in Table A, they click the "Add Activity" button which invokes the API call. They then arrive at the form to create an Activity record in Table B with the mutual information from the Task record. This is all working as intended. Though, this process happens so often in a day it would actually be a large time size to combine saving the Task record in Table A when you click the "Add Activity" button to go to the form in Table B to create an Activity record. The goal is the user does not have to click the green save button in the top right corner in order to click the button to invoke the API call. I hope the intended purpose is more clear now
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 53,570 Points 50k badge 2x thumb
Mathew has posted the check box to check.