Two API Calls in a Row

  • 0
  • 1
  • Question
  • Updated 3 months ago
  • Answered
I'm trying to run consecutive API calls, (no tokens), and it's not working.  Each call works fine separately, but when run together, the first one executes but the second one is ignored.  If I swap $URLTWO with $URLONE, $URLTWO executes but not $URLONE.  My code is below:

var text bgcolor = "red";
var text txtcolor = "black";

var text URLONE = "https://myqb/db/mydbid?act=API_EditRecord&rid="&[Record ID#] & "&_fid_215="&[SalesOrderNum];

var text URLTWO = "https://myqb/db/mydbid?act=API_SetDBVar&varname=SalesOrderNum&value=&q...;

"<a style=\"text-decoration: none; width:200px; background:" & $bgcolor & "; height: 30px; color:"  & $txtcolor & "; padding: 7px 10px; display: inline-block; text-align: center;\"  href=\"javascript:" & "$.get('" & $URLONE & "&rdr=" & URLEncode($URLTWO) &
    "', function(){" & "location.reload();" & "});" &
    "void(0);\">SONumber?</a>"

[SalesOrderNum] is an app variable.  I've tried this with and without the "&rdr=", same result.

Thank you!
Photo of Ken Casser

Ken Casser

  • 612 Points 500 badge 2x thumb

Posted 3 months ago

  • 0
  • 1
Photo of Ken Casser

Ken Casser

  • 612 Points 500 badge 2x thumb
Something altered my var text URLTWO and truncated it, but that shouldn't affect finding my error.
Photo of Jason

Jason

  • 1,012 Points 1k badge 2x thumb
I have a sample of how I am performing 2 separate API's in a button. In this example I am performing an edit then an add in another table. The key is wrapping the next API in a double URLEncode.  I included a style I have used that has a mouse over color change.


// Begin button style

var text bgcolor = "#808080";

var text bgcolorm = "#a1a1a1";

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() & "?a=API_EditRecord&rid="& [Record ID#] &

"&_fid_1034=1"

& "&rdr="

& URLEncode(URLEncode(URLRoot() & "db/"& [_DBID_B]  & "?a=API_AddRecord"

& "&_fid_6=" & [Store #]

& "&_fid_7=" & [New Store Integration Services]

& "&_fid_8=" & [Project ID]

& "&_fid_10=" & URLEncode([Task Number])

& "&_fid_42=1"));

 

"<a " & $style & " href=\"javascript:"

& "$.get('" & $URL

& "', function(){"

& "location.reload();"

&  "});" & "void(0);\">Bill Integration Service</a>"






Photo of Ken Casser

Ken Casser

  • 612 Points 500 badge 2x thumb
Magic!  Thank you!!!