How can I direct a script to move to the next condition if the current condition is false?

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

I have a script where multiple conditions may be present on the parent table and based on those conditions, new records will be automatically added to the child table at the click of a button.  The issue I'm having is if the first condition is met but the second condition is not met, the script stops.  For instance, I'm asking to return the results for a specific field but if nothing is in that field a blank record is created and then the script stops running.  How can I redirect so that if a condition is not met, it will ignore that condition and move onto the next one?  Below is an example of my script.

var text AddRecordOne= 

URLRoot()&"db/"&[_DBID_FEES]

&"?act=API_AddRecord&apptoken=dmyx5n7dc5fkbqbj2bq9ndvst42p&_fid_130="&URLEncode([Account ID#]) & "&z="&Rurl()

&"&_fid_129="&URLEncode([Account Closure fee])

&"&_fid_134="&URLEncode([Account Number]);


var text AddRecordTwo= 

URLRoot()&"db/"&[_DBID_FEES]

&"?act=API_AddRecord&apptoken=dmyx5n7dc5fkbqbj2bq9ndvst42p&_fid_130="&URLEncode([Account ID#]) & "&z="&Rurl()

&"&_fid_129="&URLEncode([ACH Fee])

&"&_fid_134="&URLEncode([Account Number]);


var text AddRecordThree= 

URLRoot()&"db/"&[_DBID_FEES]

&"?act=API_AddRecord&apptoken=dmyx5n7dc5fkbqbj2bq9ndvst42p&_fid_130="&URLEncode([Account ID#]) & "&z="&Rurl()

&"&_fid_129="&URLEncode([Expedited Fee])

&"&_fid_134="&URLEncode([Account Number]);

Photo of Christine

Christine

  • 130 Points 100 badge 2x thumb

Posted 3 years ago

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

QuickBaseCoach App Dev./Training, Champion

  • 67,448 Points 50k badge 2x thumb
Can you post your whole formula?
Photo of Christine

Christine

  • 130 Points 100 badge 2x thumb
I'm also having an issue with the display record piece of my formula.  I receive an error message, so I'm not being redirected back to my parent table...

var text AddRecordOne=
URLRoot()&"db/"&[_DBID_FEES]
&"?act=API_AddRecord&apptoken=dmyx5n7dc5fkbqbj2bq9ndvst42p&_fid_130="&URLEncode([Account ID#]) & "&z="&Rurl()
&"&_fid_129="&URLEncode([Account Closure fee])
&"&_fid_134="&URLEncode([Account Number]);

var text AddRecordTwo=
URLRoot()&"db/"&[_DBID_FEES]
&"?act=API_AddRecord&apptoken=dmyx5n7dc5fkbqbj2bq9ndvst42p&_fid_130="&URLEncode([Account ID#]) & "&z="&Rurl()
&"&_fid_129="&URLEncode([ACH Fee])
&"&_fid_134="&URLEncode([Account Number]);

var text AddRecordThree=
URLRoot()&"db/"&[_DBID_FEES]
&"?act=API_AddRecord&apptoken=dmyx5n7dc5fkbqbj2bq9ndvst42p&_fid_130="&URLEncode([Account ID#]) & "&z="&Rurl()
&"&_fid_129="&URLEncode([Expedited Fee])
&"&_fid_134="&URLEncode([Account Number]);

var text AddRecordFour=
URLRoot()&"db/"&[_DBID_FEES]
&"?act=API_AddRecord&apptoken=dmyx5n7dc5fkbqbj2bq9ndvst42p&_fid_130="&URLEncode([Account ID#]) & "&z="&Rurl()
&"&_fid_129="&URLEncode([Fed Withholding])
&"&_fid_134="&URLEncode([Account Number]);

var text AddRecordFive=
URLRoot()&"db/"&[_DBID_FEES]
&"?act=API_AddRecord&apptoken=dmyx5n7dc5fkbqbj2bq9ndvst42p&_fid_130="&URLEncode([Account ID#]) & "&z="&Rurl()
&"&_fid_129="&URLEncode([Interest])
&"&_fid_134="&URLEncode([Account Number]);

var text AddRecordSix=
URLRoot()&"db/"&[_DBID_FEES]
&"?act=API_AddRecord&apptoken=dmyx5n7dc5fkbqbj2bq9ndvst42p&_fid_130="&URLEncode([Account ID#]) & "&z="&Rurl()
&"&_fid_129="&URLEncode([State Withholding])
&"&_fid_134="&URLEncode([Account Number]);

var text AddRecordSeven=
URLRoot()&"db/"&[_DBID_FEES]
&"?act=API_AddRecord&apptoken=dmyx5n7dc5fkbqbj2bq9ndvst42p&_fid_130="&URLEncode([Account ID#]) & "&z="&Rurl()
&"&_fid_129="&URLEncode([Treasurer Check Fee])
&"&_fid_134="&URLEncode([Account Number]);

var text AddRecordEight=
URLRoot()&"db/"&[_DBID_FEES]
&"?act=API_AddRecord&apptoken=dmyx5n7dc5fkbqbj2bq9ndvst42p&_fid_130="&URLEncode([Account ID#]) & "&z="&Rurl()
&"&_fid_129="&URLEncode([Wire Fee])
&"&_fid_134="&URLEncode([Account Number]);

var text DisplayRecord=
URLRoot()&"db/"& Dbid()
&"?a=dr&rid="&[Account ID#];

$ADDRECORDOne&"&rdr="&URLEncode($ADDRECORDTwo)
&URLEncode("&rdr="&URLEncode($ADDRECORDThree))
&URLEncode("&rdr="&URLEncode($ADDRECORDFour))
&URLEncode("&rdr="&URLEncode($ADDRECORDFive))
&URLEncode("&rdr="&URLEncode($ADDRECORDSix))
&URLEncode("&rdr="&URLEncode($ADDRECORDSeven))
&URLEncode("&rdr="&URLEncode($ADDRECORDEight))
&URLEncode("&rdr="&URLEncode($DisplayRecord))
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,448 Points 50k badge 2x thumb
That syntax for nesting is not correct.

Here is an example of syntax which does work.
Note, however, that while QuickBase does not seem to mind the nesting, the result is an extremenly long URL which may exceed the limits of your browser.  IR probably has a limit of about 2000 characters and Chriome and FF have a much higher limit.

I'm understanding though in your question about the Conditions being met.


$URLZero
& "&rdr=" & URLEncode($URLOne)
& URLEncode("&rdr=" & URLEncode($URLTwo))
& URLEncode(URLEncode("&rdr=" & URLEncode($URLThree)))
& URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLFour))))
& URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLFive)))))
& URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLSix))))))
& URLENcode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLSeven)))))))
& URLENcode(URLENcode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLEight))))))))
& URLENcode(URLENcode(URLENcode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLNine)))))))))
& URLENcode(URLENcode(URLENcode(URLENcode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLTen))))))))))
Photo of Christine

Christine

  • 130 Points 100 badge 2x thumb
Fixing the syntax redirected me back to the parent record AND it also corrected the issue that I was having with the conditions being met!!  Thank you so much for your help!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,448 Points 50k badge 2x thumb
Thx for letting me know.