Is there a way to add a record (using a formula button in a report) without being redirected to that record?

  • 0
  • 1
  • Question
  • Updated 4 months ago
  • Answered
I would like to create child "IRR" records from a report of parent "ticker" records by just clicking a button. I currently have the "Add IRR" button 
URLRoot() & "db/" & [_DBID_IRR] & "?a=API_GenAddRecordForm&_fid_10=" & URLEncode ([Record ID#])& "&z=" & Rurl()
but I want it to stay on the report view and just create the record in the background

I know I can do a workaround by using an action triggered by a checkbox, but I don't want to have to edit the parent record

Is there a way I can adjust the existing button code?

Thanks
Photo of Rebecca L

Rebecca L

  • 352 Points 250 badge 2x thumb

Posted 4 months ago

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

QuickBaseCoach App Dev./Training, Champion

  • 51,036 Points 50k badge 2x thumb
Do you want to refresh the report / record you are on or just have a quiet fade away pop up saying that the record has been added?
Photo of Rebecca L

Rebecca L

  • 352 Points 250 badge 2x thumb
no need to refresh, I'd rather not have to wait that extra second between clicks
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,036 Points 50k badge 2x thumb
Here is an example.  You will need to disable the need for app tokens or else add a line to the code like

& "&apptoken=xxxxxxxxxx"

var datetime SnoozeUntil = ToTimestamp(Today() + Days(1), ToTimeOfDay("0:00"));


var text URL = URLRoot() & "db/" & [_DBID_DEALLOCATION_CANDIDATES] & "?act=API_EditRecord"
 & "&rid=" & [Record ID#]
 & "&apptoken=xxxxxxxxxx"
 & "&_fid_415=" & ToText($SnoozeUntil)
 & "&_fid_416=" & ToText(Now()); // set the date/time so we know if the line existed when snoozed


 
"javascript:" &
"$.get('" & 
$url & 
"',function(){" &
"$.jGrowl('put your pop up words here', {life: 5000, theme: 'jGrowl-green'});" &
"});" &
"void(0);"
Photo of Rebecca L

Rebecca L

  • 352 Points 250 badge 2x thumb
I get an error for [_DBID_DEALLOCATION_CANDIDATES]  what is that supposed to refer to?
Photo of Rebecca L

Rebecca L

  • 352 Points 250 badge 2x thumb
Also, the popup is not necessary
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,036 Points 50k badge 2x thumb
You will want to let the user know that clicking the button "worked' or else they will just keep on clicking it and lot of child records will be created.  In any event, the pop up does not slow down the process.   The 5000 means 5 seconds before the pop up fades away on its own.  You can adjust that as you like.
Photo of Rebecca L

Rebecca L

  • 352 Points 250 badge 2x thumb
I see what you are saying, thanks. Now the popup is working and it creates the record in IRR but the record is not connected to the ticker (parent record)
This is what I have:

var datetime SnoozeUntil = ToTimestamp(Today() + Days(1), ToTimeOfDay("0:00"));


var text URL = URLRoot() & "db/" & [_DBID_IRR] & "?act=API_AddRecord"
 & "&rid=" & [Record ID#]
 & "&apptoken=qqj2k7wz..."
 & "&_fid_415=" & ToText($SnoozeUntil)
 & "&_fid_416=" & ToText(Now()); // set the date/time so we know if the line existed when snoozed


 
"javascript:" &
"$.get('" & 
$url & 
"',function(){" &
"$.jGrowl('Record Added', {life: 5000, theme: 'jGrowl-green'});" &
"});" &
"void(0);"
Photo of Rebecca L

Rebecca L

  • 352 Points 250 badge 2x thumb
I got It! 
var text URL = URLRoot() & "db/" & [_DBID_IRR] & "?act=API_AddRecord"
 & "&_fid_10=" & URLEncode([Record ID#])

Thanks for your help!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,036 Points 50k badge 2x thumb
OK, so you are not understanding my example,

a line like this 

& "&_fid_416=" & ToText(Now())

means to populate fid 416 with a value.

so similar to your original formula
 you need to put in a line like 

&_fid_10=" & URLEncode ([Record ID#])


to connect the child to the Parent because your field 10 is the field for [Related Parent]