Skip to main content
Question

Can't seem to get redirect to work after API Call

  • Oct 17, 2017 7:48 PM UTC
  • 0 replies
  • 51 views

I'm using the following:
var date RightNow = Today(); 
var text Close = "CLOSED";
var text URLONE = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord" 
& "&rid=" & [Record ID#] 
& "&_fid_18=" & $Close
& "&_fid_23=" & $RightNow;
var text URLTWO = URLRoot() & "db/" & [_DBID_ACTIVITY_LOG_DAVE] & "?a=API_AddRecord"
& "&_fid_47=" &URLEncode ([Record ID#]) 
& "&_fid_50=" &URLEncode([Company Name (ref)]) 
& "&_fid_97=" &URLEncode([User #]) 
& "&_fid_31=" &URLEncode([Now]) 
& "&_fid_22=" &URLEncode("Stuff")
& "&_fid_11=" &URLEncode("More Stuff")
& "&_fid_12=" &URLEncode("0.05");
var text URLTHREE = URLRoot() & "db/" & Dbid() & "a=dr&rid" & [Record ID#];
$URLONE
&"&rdr=" & URLEncode($URLTWO)
&URLEncode("&rdr="&URLEncode($URLTHREE))
Although I can't seem to get the third URL to work so I stay on the same page. The actual use of the button is that, you click it and it updates the current parent records you are in. Creates the cookie cutter child record, then I would like to remain in the parent record.
This topic has been closed for replies.

  • Qrew Corporal
  • Oct 17, 2017 7:54 PM UTC
Does the edit and the add record portion work?  It looks like you might need an apptoken.

Also, rather than redirecting to the parent, try just have the page refresh; (similar to this)

"javascript:" &"$.get('" & $URL & "',
function(){" &"location.reload(true);" &"}); " & "void(0);

  • Author
  • Qrew Corporal
  • Oct 17, 2017 8:06 PM UTC
The first two API calls are working. I was ending up on the XML post with error code 0 telling me it worked.  I removed URLTHREE, and tried replacing the bottom with:

"javascript:" &"$.get('" & 
$URLONE
&"&rdr=" & URLEncode($URLTWO) &
"',function(){" &
"location.reload(true);" &
"});" 
& "void(0);"&
"}"
Though, I have a feeling I put the reload in the wrong spot as neither of the calls work now, or is the page refreshing.

  • Author
  • Qrew Corporal
  • Oct 17, 2017 8:49 PM UTC
So now I have:

var date RightNow = Today(); 
var text Close = "CLOSED";

var text URLONE = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord" 
& "&rid=" & [Record ID#] 
& "&_fid_18=" & $Close
& "&_fid_23=" & $RightNow;

var text URLTWO = URLRoot() & "db/" & [_DBID_ACTIVITY_LOG_DAVE] & "?a=API_AddRecord"
& "&_fid_47=" &URLEncode ([Record ID#]) 
& "&_fid_50=" &URLEncode([Company Name (ref)]) 
& "&_fid_97=" &URLEncode([User #]) 
& "&_fid_31=" &URLEncode([Now]) 
& "&_fid_22=" &URLEncode("Stuff")
& "&_fid_11=" &URLEncode("More Stuff")
& "&_fid_12=" &URLEncode("0.05");

"javascript:" &
"location.reload(true);" &
"$.get('" & 
$URLONE
&"&rdr=" & URLEncode($URLTWO) &
"');" &
"void(0);"

The page is reloading but now neither of the API calls are working

Jordan, your original method was correct and will work.

The problem is here

var text URLTHREE = URLRoot() & "db/" & Dbid() & "a=dr&rid" & [Record ID#];

it needs to say ....  & "a=dr&rid=" & [Record ID#];

Missing the = after rid

  • Author
  • Qrew Corporal
  • Oct 17, 2017 10:02 PM UTC
Oh wow, at least it was something simple, thank you!