Discussions

Expand all | Collapse all

Two API Calls in a Row

  • 1.  Two API Calls in a Row

    Posted 08-07-2018 15:09
    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!


  • 2.  RE: Two API Calls in a Row

    Posted 08-07-2018 15:11
    Something altered my var text URLTWO and truncated it, but that shouldn't affect finding my error.


  • 3.  RE: Two API Calls in a Row

    Posted 08-07-2018 20:53
    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>"








  • 4.  RE: Two API Calls in a Row

    Posted 08-07-2018 20:59
    Magic!  Thank you!!!