Forum Discussion

JeffMickelsen's avatar
JeffMickelsen
Qrew Cadet
7 years ago

Combine 4 URL's in one button

I have 4 URLs that each work fine by themselves.  I downloaded the URL Formula Buttons for dummies and can combine three of the URLs using that example.  However, I need to add a fourth url to the button and I can't figure out the syntax.

Below is listed what I have so far.

var text DeliveryDateInOS =
    URLRoot() & "db/xxx?a=API_EditRecord" &
    "&rid=" & URLEncode([DeliveryOrderSched]) &
    "&apptoken=XXX" &
    "&_fid_7=" & URLEncode([Dumpster Delivery Date] & " 12:00am") &
    "&_fid_18=" & URLEncode([Dumpster Delivery Date] & " 12:30am");

var text PickUpDateInOS =
    URLRoot() & "db/xxx?a=API_EditRecord" &
    "&rid=" & URLEncode([PickupOrderSched]) &
    "&apptoken=XXX" &
    "&_fid_7=" & URLEncode([Dumpster Pick-up Date] & " 1:00am") &
    "&_fid_18=" & URLEncode([Dumpster Pick-up Date] & " 2:00am");

var text ProcessRec =
    URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
    "&rid=" & [Order Number] &
    "&apptoken=XXX" &
    "&_fid_77=0" &
    "&_fid-434=1"&
    "&_fid_447=1"&
    "&_fid_79=" & URLEncode(Trim(ToText([Dumpster charge - DumpsterCost]))) &
    "&_fid_169=" & URLEncode(Max([ZipCodeReference - MileageCharge],0)) &
    "&_fid_71=1" ;

$DeliveryDateInOS &
"&rdr=" & URLEncode($PickupDateInOS) & 
URLEncode("&rdr=" & URLEncode($DeliveryDateInOS)) &
URLEncode("&rdr=" & URLEncode(URLRoot() & "db/" & Dbid()&"?a=dr&rid="&[Order Number]))

Obviously, I  have overwritten the DBID and the AppToken for each url.

Can anyone shed some light on what I am doing wrong?
  • My recommendation with that much going on is you're better off in the long run just writing some quick javascript to accomplish your goal. Makes it much easier to scale if you want to add a 5th, or 6th... so on. 

    Your syntax in a url button would look like:

    "javascript: {" & 
    "$.get('" & $DeliveryDateInOS  & "');" & 
    "$.get('" & $PickUpDateInOS   & "');" &
    "$.get('" & $ProcessRec & "');" &
    "window.location.replace('" & URLRoot() & "db/" & Dbid()&"?a=dr&rid="&[Order Number]) & "');" & 
    "}"

    The $.get() commands will call out to perform the editRecord Calls - then when complete it does your redirect via window.location.replace. Quick note if you go this route and want to add to it - make sure you're putting single quotes in your $.gets() - its a little hard to see written above. So the real syntax looks like $.get(' but since its a quick base formula it has to have double quotes for the formula like "$.get('"


    Chayce Duncan | Technical Lead
    (720) 739-1406 | chayceduncan@quandarycg.com
    Quandary Knowledge Base
  • The other syntax is this to execute sequential URL calls

    $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)))))


    You define the formula variables and need to end with one that displays a record or a report.

    But Chayce, yours could probably be made more generic for the situation where you want to refresh whatever page you are on.  That way it would be more flexible to be used on a record or a report or an embedded child table on a form and be superior to mine for that situation.  Is there a change to yours possible which would do that?




    • ChayceDuncan2's avatar
      ChayceDuncan2
      Qrew Cadet
      Coach - your point is actually the reason I've converted most of my buttons to work like that, to cover that exact scenario of reloading the page rather than having to define the redirect all the time. The simple change is to swap out window.location.replace with location.reload() - so the updated formula from my example above would be:

      "javascript: {" & 
      "$.get('" & $DeliveryDateInOS  & "');" & 
      "$.get('" & $PickUpDateInOS   & "');" & 
      "$.get('" & $ProcessRec & "');" & 
      "location.reload();" & 
      "}" 


      Chayce Duncan | Technical Lead
      (720) 739-1406 | chayceduncan@quandarycg.com
      Quandary Knowledge Base
    • QuickBaseCoachD's avatar
      QuickBaseCoachD
      Qrew Captain
      Thx for posting that.  The other advantage of the javascript method is that if you get really deep with nesting the URL gets exponentially longer due to the nested URLEncodes and eventually it gets over 2,000 characters and some Browsers like IE have limits on URL length.
    • ChayceDuncan2's avatar
      ChayceDuncan2
      Qrew Cadet
      Agreed. The other potential avenue too in situations like this, javascript enables you to interpret the responses - so if you were doing several add records instead of edits - you can add in some $.get(...).then(function(res){...}) in one or all of your requests and you could log out or play around with the new records that are created.

      Chayce Duncan | Technical Lead
      (720) 739-1406 | chayceduncan@quandarycg.com
      Quandary Knowledge Base
  • Thank you both so much.  I have beat my head against the wall trying to figure this out.