Nesting URL API Calls in one Button
So, for years now this is one feature that has always eluded me due to the fact that I've never been able to get it to work.
How does one nest multiple API calls in a single button? I've read the old article that talks about "rdr" and such, but the example only shows a single API call which doesn't help. Right now I need this single button to ADD a new record in a specific table, which it does, but then EDIT the parent and then RETURN to the parent in edit mode. This is what I have currently:
var text URLTwo =
URLRoot() & "db/" & [_DBID_TABLENAME] & "?a=API_EditRecord=" & "&apptoken=APPTROKEN"
& (If([THING1]=false, "&_fid_312=false" & "&_fid_304=false",""))
& (If([THING2]=false, "&_fid_36=false" & "&_fid_305=false",""))
& (If([THING3]=false, "&_fid_37=false" & "&_fid_306=false",""));
var text URLOne =
URLRoot() & "db/" &[_DBID_TABLENAME]& "?a=API_AddRecord" & "&apptoken=APPTROKEN"
& "&_fid_6=" & [Record ID#]
& "&_fid_7=" & URLEncode(User())
& "&_fid_8=" & Now()
& "&_fid_9=" & "Returned"
& "&_fid_23=" & $VARIABLE1
& "&_fid_24=" & $VARIABLE2
& "&_fid_25=" & $VARIABLE3 ;
//Return Button
var text ReturnButtonURL =
$URLOne
& URLEncode("&rdr=" & ($URLTwo))
& "&rdr=" & $ReturnURL ;
I've tried every variation I can think of with URLEncode(), but the only thing it does is run the FIRST API call which is API_AddRecord. It runs that, then dumps me at the app's homepage. Not once has it ran the second API_EditRecord call. Again, it ALWAYS creates the required record, but the next steps do nothing.
Any insight on this would be ultra-appreciated.
Yep, been there, done it, bought the T-Shirt.
It's unpublished and I really struggled with that too, a decade or two ago.
Here is the generic syntax. Just slice off as must of the salami as you need, keeping in mind that the last URL call needs to land the user on a record or a report or a Dashboard page or just refresh the page, or else it will spew the last XML success message back at the user.
$URLONE
& "&rdr=" & URLEncode($URLTWO)
& URLEncode("&rdr=" & URLEncode($URLTHREE))
& URLEncode(URLEncode("&rdr=" & URLEncode($URLFOUR)))
& URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLFIVE))))
& URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLSIX)))))
& URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLSEVEN))))))If you copy paste to a Quickbase record or Word doc it won't wrap and it will be easier to see the pattern.
I have longer versions too. At some point the URL gets too long for some browsers to handle.
If you want to just refresh the page you are on, you can end with this step as $RefreshPage
var text RefreshPage = URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();