Skip to main content
Solved

Nesting URL API Calls in one Button

  • September 17, 2024
  • 0 replies
  • 468 views

Forum|alt.badge.img+3

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.

Best answer by MarkShnierYou

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();

 

 

 

This topic has been closed for replies.

MarkShnierYou
Forum|alt.badge.img+24

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();

 

 

 


MarkShnierYou
Forum|alt.badge.img+24

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();

 

 

 


Forum|alt.badge.img+3
  • Author
  • Registered
  • September 17, 2024

Hey Mark, thanks for the reply.  I've restructured my nested URL variables as you showed above, but as far as I can tell the system is still only running the first API call; i.e. it isn't editing the parent and then still dumps me back at the app homepage.

Is it not possible to go from an API_AddRecord run to an API_EditRecord run in the same button?


Forum|alt.badge.img+3
  • Author
  • Registered
  • September 17, 2024

Ah, disregard... In my hours of work on the URL chaining syntax, I missed a single "&rid=" in one of the URL's.  So after fixing that... IT WORKS!!!

You have my thanks Mark!