Is there a maximum of VAR in URL Formula ?

  • 0
  • 1
  • Question
  • Updated 1 month ago
  • In Progress
  • (Edited)
I am trying to use the following code in a URL Formula, but it's runs till after line # 9!!!

Can one please help me to tell me what I am doing wrong here?

--------------------------------------------------------------------------------------------------------------------

var text URLONE = URLRoot() & "db/" & [_DBID_WAREHOUSE_ITEMS] & "?act=API_RunImport&ID=10";
var text URLTWO = URLRoot() & "db/" & [_DBID_WAREHOUSE_ITEMS] & "?act=API_RunImport&ID=11";
var text URLTHREE = URLRoot() & "db/" & [_DBID_WAREHOUSE_ITEMS] & "?act=API_RunImport&ID=12";
var text URLFour = URLRoot() & "db/" & [_DBID_WAREHOUSE_ITEMS] & "?act=API_RunImport&ID=13";
var text URLFIVE = URLRoot() & "db/" & [_DBID_WAREHOUSE_PRODUCTS] & "?act=API_RunImport&ID=10";
var text URLSIX = URLRoot() & "db/" & [_DBID_WAREHOUSE_PRODUCTS] & "?act=API_RunImport&ID=11";
var text URLSEVEN = URLRoot() & "db/" & [_DBID_WAREHOUSE_PRODUCTS] & "?act=API_RunImport&ID=12";
var text URLEIGHT = URLRoot() & "db/" & [_DBID_WAREHOUSE_PRODUCTS] & "?act=API_RunImport&ID=13";
var text URLnine = URLRoot() & "db/" & [_DBID_SKU_ITEM_ASSIGNMENTS] & "?act=API_RunImport&ID=10";
var text URLten = URLRoot() & "db/" & [_DBID_SKU_ITEM_ASSIGNMENTS] & "?act=API_RunImport&ID=11";
var text URLeleven = URLRoot() & "db/" & [_DBID_SKU_ITEM_ASSIGNMENTS] & "?act=API_RunImport&ID=12";
var text URLtwelve = URLRoot() & "db/" & [_DBID_SKU_ITEM_ASSIGNMENTS] & "?act=API_RunImport&ID=13";
var text URLthirteen  = URLRoot() & "db/" &  [_DBID_SKU_ITEM_ASSIGNMENTS] & "?a=API_PurgeRecords&qid=17";
var text URLfourteen  = URLRoot() & "db/" &  [_DBID_WAREHOUSE_ITEMS] & "?a=API_PurgeRecords&qid=14";
var text URLfifteen  = URLRoot() & "db/" &  [_DBID_WAREHOUSE_PRODUCTS] & "?a=API_PurgeRecords&qid=14";
  
$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))))))
& URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLEIGHT)))))))
& URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLNINE))))))))
& URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLTEN))))))))))
& URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLeleven)))))))))))
& URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLtwelve)))))))))))
& URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLthirteen)))))))))))
& URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLfourteen)))))))))))))))))
& URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLfifteen)))))))))))))

--------------------------------------

For more clarification, here is an screenshare  

https://www.screencast.com/t/cIy8zXSig

Photo of Sam Krausz

Sam Krausz

  • 470 Points 250 badge 2x thumb

Posted 5 months ago

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

QuickBaseCoach App Dev./Training, Champion

  • 51,346 Points 50k badge 2x thumb
There are Browser limits to the maximum length of a URL.. Internet Explorer has a limit of 2083 characters and other browsers will have larger limits.  You could expose the URL itself on a form by removing its label and copy and paste into Word and use the tool to count characters to see how long it is.

An alternative is to use an Automation to do these steps.  You would trigger it by toggling a checkbox field.

The issue there will be the last three steps which is deleting records.  For reasons I do not understand, the records are deleted "one by one", so its super slow to run as opposed to it being programmed to use API_Purge, which always seems to run instantly.  If you have thousands of records to delete it will take a while to run and may even time out, I suppose. 
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,522 Points 20k badge 2x thumb
Fill in your dbid's and apptoken and bind this code to a button:

(function() {
  var dbidWarehouseItems = "";
  var dbidWarehouseProducts = "";
  var dbidSkuItemAssignments = "";
  var apptoken = "";
  $.ajaxSetup({date: {apptiken: apptoken}});
  $("a.QBU_Button").on("click", function(event) {
    $("<img>", {
      src: "https://cdnjs.cloudflare.com/ajax/libs/galleriffic/2.0.1/css/loader.gif",
      id: "QBU_Spinner"
    }).css({
      position: "fixed",
      top: "50%",
      left: "50%",
      transform: "translate(-50%, -50%)"
    }).appendTo("body");
    
    $.when(
      $.post(dbidWarehouseItems,     {act: "API_RunImport",    id: 10}),
      $.post(dbidWarehouseItems,     {act: "API_RunImport",    id: 11}),
      $.post(dbidWarehouseItems,     {act: "API_RunImport",    id: 12}),
      $.post(dbidWarehouseItems,     {act: "API_RunImport",    id: 13}),
      $.post(dbidWarehouseProducts,  {act: "API_RunImport",    id: 10}),
      $.post(dbidWarehouseProducts,  {act: "API_RunImport",    id: 11}), 
      $.post(dbidWarehouseProducts,  {act: "API_RunImport",    id: 12}),
      $.post(dbidWarehouseProducts,  {act: "API_RunImport",    id: 13}), 
      $.post(dbidSkuItemAssignments, {act: "API_RunImport",    id: 10}),
      $.post(dbidSkuItemAssignments, {act: "API_RunImport",    id: 11}),
      $.post(dbidSkuItemAssignments, {act: "API_RunImport",    id: 12}),
      $.post(dbidSkuItemAssignments, {act: "API_RunImport",    id: 13}),
      $.post(dbidWarehouseItems,     {act: "API_PurgeRecords", id: 14}),
      $.post(dbidWarehouseProducts,  {act: "API_PurgeRecords", id: 14}),
      $.post(dbidSkuItemAssignments, {act: "API_PurgeRecords", id: 17})
    ).then(function() {
      $("#QBU_Spinner").hide();
      // further code here
    });
  });
})();

Notes:

(1) I am assuming that the order that these API methods are executed in is not relevant, Also, I would not extend the code much beyond the 15 API calls as at some point your browser might become unresponsive and run out of sockets. You should be quite safe at 15 calls,

(2) The code will display a spinner during the execution of the API methods and will hide the spinner when API methods are all complete,
(Edited)
Photo of Sam Krausz

Sam Krausz

  • 470 Points 250 badge 2x thumb
Thanks all for your response, it's all really helpful

Dear Den

Where should I place this code?

How will this code be executed? what should I click in order to run this?

I am very unfamiliar with code in Quickbase, if you can help me for a minute we all here in our company will appricted it....
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,522 Points 20k badge 2x thumb
If you are unfamiliar with using code, I would suggest you employ consulting.

Even if you were familiar with using code, I would suggest you do your initial implementation in a copy of your application because the script adds and deletes multiple records without any confirmation. 

If you need help please feel free to contact me off-world using the information in my profile:

https://getsatisfaction.com/people/dandiebolt
Photo of Jason

Jason

  • 1,012 Points 1k badge 2x thumb
I have never tried that many API_RunImports using my preferred method of a Rich Text Formula. It isn't code like Dan but it is more fun than the original code and I like how it reads.

// Begin button style
var text bgcolor = "#0068b3";
var text bgcolorm = "#008BEE";
var text txtcolor = "white";

var text style = "style=\"text-decoration: none; box-shadow: 3px 3px 1px #888888;background:" & $bgcolor & "; color: " & $txtcolor & "; border-radius: 3px; padding: 5px 8px; display: inline-block;  font-weight: normal;font: 700 24px/1 \"Calibri\", sans-serif; \" onMouseOver=\"this.style.backgroundColor='" & $bgcolorm & "'\";\" onMouseOut=\"this.style.backgroundColor='" & $bgcolor & "'\"; text-align: center; text-shadow:none;";
// End button style

var text URL = URLRoot() & "db/" & [_DBID_WAREHOUSE_ITEMS] & "?act=API_RunImport&ID=10"
& "&rdr="
& URLEncode(URLEncode(URLRoot() & "db/" & [_DBID_WAREHOUSE_ITEMS] & "?act=API_RunImport&ID=11"
& "&rdr="
& URLEncode(URLRoot() & "db/" & [_DBID_WAREHOUSE_ITEMS] & "?act=API_RunImport&ID=12"
& "&rdr="
& URLEncode(URLRoot() & "db/" & [_DBID_WAREHOUSE_ITEMS] & "?act=API_RunImport&ID=13"
& "&rdr="
& URLEncode(URLRoot() & "db/" & [_DBID_WAREHOUSE_PRODUCTS] & "?act=API_RunImport&ID=10"
& "&rdr="
& URLEncode(URLRoot() & "db/" & [_DBID_WAREHOUSE_PRODUCTS] & "?act=API_RunImport&ID=11"
& "&rdr="
& URLEncode(URLRoot() & "db/" & [_DBID_WAREHOUSE_PRODUCTS] & "?act=API_RunImport&ID=12"
& "&rdr="
& URLEncode(URLRoot() & "db/" & [_DBID_WAREHOUSE_PRODUCTS] & "?act=API_RunImport&ID=13"
& "&rdr="
& URLEncode(URLRoot() & "db/" &[_DBID_SKU_ITEM_ASSIGNMENTS] & "?act=API_RunImport&ID=10"
& "&rdr="
& URLEncode(URLRoot() & "db/" &[_DBID_SKU_ITEM_ASSIGNMENTS] & "?act=API_RunImport&ID=11"
& "&rdr="
& URLEncode(URLRoot() & "db/" &[_DBID_SKU_ITEM_ASSIGNMENTS] & "?act=API_RunImport&ID=12"
& "&rdr="
& URLEncode(URLRoot() & "db/" &[_DBID_SKU_ITEM_ASSIGNMENTS] & "?act=API_RunImport&ID=13"
& "&rdr="
& URLEncode(URLRoot() & "db/" &  [_DBID_SKU_ITEM_ASSIGNMENTS] & "?a=API_PurgeRecords&qid=17"
& "&rdr="
& URLEncode(URLRoot() & "db/" &[_DBID_WAREHOUSE_ITEMS] & "?a=API_PurgeRecords&qid=14"
& "&rdr="
& URLEncode(URLRoot() & "db/" &  [_DBID_WAREHOUSE_PRODUCTS] & "?a=API_PurgeRecords&qid=14")))))))))))))));

"<a " & $style & " href=\"javascript:" & "$.get('" & $URL & "', function(){" & "location.reload();" &
 "});" & "void(0);\"> Down to One Var but is it still too many lines for the browser </a>"