Add a record using Formula URL and pre-populate fields

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

Hello, I would like to add a new "Add" button in the home page, but with some fields already preselected (I don't want them to be default values, this is why I want to add a new button). To do so, I created a new Formula URL in my form, in order to add the URL in the hope page, but when I press it, how can I remain in the newly created record since there is no Record ID yet? 


URLRoot()& "db/" &[_DBID_REQUESTS]& "?a=API_AddRecord" &  "&apptoken=b69zinjch2jdtk4yatybwhjspa"& "&_fid_16=Embroidery" & URLEncode ([Record ID#])

Photo of Spyros

Spyros

  • 32 Points

Posted 3 years ago

  • 0
  • 1
No problem to stick in view mode. Just suffix this to the end if your URL formula m

& "&disprec=1"

In english it says It says "and display record + true"



URLRoot()& "db/" &[_DBID_REQUESTS]& "?a=API_AddRecord" &  "&apptoken=b69zinjch2jdtk4yatybwhjspa"& "&_fid_16=Embroidery" & URLEncode ([Record ID#])

& "&disprec=1"
Photo of Spyros

Spyros

  • 32 Points
Thank you for your answer!
How could I see the record in edit mode?
I updated the url to the following, but I am in a read mode.

Is it possible?

Thanks!

URLRoot()& "db/" &[_DBID_REQUESTS]& "?a=API_AddRecord" &
"&apptoken=b69zinjch2jdtk4yatybwhjspa"&
"&_fid_16=Embroidery" &
 "&disprec=1" &
"&rdr=" &
URLEncode(URLRoot() & "db/" & Dbid() &
"?a=er&rid=" & [Record ID#])
Sorry, it's not possible to land in Edit Mode.
Photo of Brandon

Brandon

  • 120 Points 100 badge 2x thumb
What if you wanted it to land on a specific form other than the default one? Say you wanted it to to land on dfid=11? Is this possible?
not tested but try this

& "&disprec=1&dfid=11"
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,224 Points 20k badge 2x thumb
You can do precisely what you want with script easily. However, QuickBase does not provide a direct way to attach JavaScript to a button on your dashboard (buttons on dashboards open new pages). So what we will do is create a Tasks table that have fields [Button], [Script], and [Description] and place the List All report for the Tasks table on your dashboard. Now you can add any number of buttons and the associated script will run without reloading your dashboard.

Here is an application that does what you want:

Create and Edit Record
https://haversineconsulting.quickbase.com/db/bk9eybbks


Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=524

You can add additional Tasks records for all the other scripts you with to run on a button click - all you have to do is provide a [Script] and [Description] field and the button action to run the script is automatically calculated.

Eventually QuickBase will wise up and replace the formula language with script to make this process easier.

Feel free to contact me off-world using the information in my profile if you need personalized assistance with implementing this fantastic feature.
Photo of Brandon

Brandon

  • 120 Points 100 badge 2x thumb
That didn't work unfortunately.
Can you post your formula?
Photo of Brandon

Brandon

  • 120 Points 100 badge 2x thumb
If([Category]="",
URLRoot() & "db/" & [_DBID_RMA] & "?a=API_AddRecord"
& "&_fid_16=Advanced Replacement"
& "&disprec=1&dfid=11",
URLRoot() & "db/" & [_DBID_RMA] &"?a=er&rid="&[Record ID#]&"&dfid=11"
)

I was trying to create a button that would act differently depending on if a new record was being added or an existing record was being edited. If it is a new record, it creates a record with a field already filled in, but it doesn't go to the correct form. It's not a big deal since the user can simply press the button again to go to an edit screen on the correct form, which isn't much different than clicking edit. I suppose I'm just curious if this is possible now.
Thx. I don't know s solution.