ELANAMETH
5 years agoQrew Cadet
Using URLEncode Conditionally
Hello,
I have an API add record button that is passing through 4 different API calls.
The first 3 are conditional (all, 1, or 2 can be called), and the 4th is always necessary.
I realize that I need to use URLEncode for any of the clauses that are not first. I cannot default them all to begin with URLEncode, as the first clause cannot have that, but I can default #4 to use it, as it will never be first.
I tried having each variable end with it so that it, but that did not work.
Any other suggestions on how to use URLEncode conditionally?
The individual variables work correctly, it's just the URLEncode for multiple calls that is messing things up.
------------------------------
E. P.
------------------------------
I have an API add record button that is passing through 4 different API calls.
The first 3 are conditional (all, 1, or 2 can be called), and the 4th is always necessary.
I realize that I need to use URLEncode for any of the clauses that are not first. I cannot default them all to begin with URLEncode, as the first clause cannot have that, but I can default #4 to use it, as it will never be first.
I tried having each variable end with it so that it, but that did not work.
Any other suggestions on how to use URLEncode conditionally?
The individual variables work correctly, it's just the URLEncode for multiple calls that is messing things up.
var text urlAddApp = URLRoot() & "db/" & [_DBID_APPS] & "?a=API_AddRecord";
var text AP = $urlAddApp & //CREATE APPLICATION
"&_fid_6=" & URLEncode ([Related Company]) &
"&_fid_20=3" & //AP application
"&_fid_8=AWAITING APPLICATION FROM WEX" &
"&apptoken=xxxxxxxxxxxxxxxxxxxxxxxxxx";
var text credit = $urlAddApp & //CREATE APPLICATION
"&_fid_6=" & URLEncode ([Related Company]) &
"&_fid_20=1" & //credit application
"&_fid_8=AWAITING APPLICATION FROM WEX" &
"&apptoken=xxxxxxxxxxxxxxxxxxxxxxxxxx";
var text prefunded = $urlAddApp & //CREATE APPLICATION
"&_fid_6=" & URLEncode ([Related Company]) &
"&_fid_20=2" & //prefunded application
"&_fid_8=AWAITING APPLICATION FROM WEX" &
"&apptoken=xxxxxxxxxxxxxxxxxxxxxxxxxx";
var text createNextActivity = URLEncode(URLRoot() & "db/" & Dbid() & "?a=API_AddRecord&_fid_18=" & URLEncode ([Related Company]) &
"&_fid_34=6" &
"&_fid_6=" & Today() &
"&_fid_66=true" &
"&apptoken=xxxxxxxxxxxxxxxxxxxxxxxxxx" &
"&rdr=" & URLEncode(URLRoot() & "db/" & [_DBID_CO] & "?a=dr&rid=" & URLEncode ([Related Company])));
var text createAppAP = If(Contains([APPLICATION TYPE], "AP"), $AP & "&rdr=" );
var text createAppCredit = If(Contains([APPLICATION TYPE], "CORPORATE CREDIT"), $credit & "&rdr=");
var text createAppPrefunded = If(Contains([APPLICATION TYPE], "CORPORATE PREFUND"), $prefunded & "&rdr=");
$createAppAP & $createAppcredit & $createAppprefunded & $createNextActivity
------------------------------
E. P.
------------------------------