Skip to main content
Question

Execute a block of code in an IF Statement

  • March 4, 2020
  • 0 replies
  • 66 views

I hope this is a simple question with an simple answer.

Is it possible to execute a block of code rather than a single action inside an IF statement?

Ex:

IF(condition, {
     command 1,
     command 2,
     ....
}



------------------------------
Paul Peterson
------------------------------
This topic has been closed for replies.

MarkShnierYou
Forum|alt.badge.img+22
  • Quickbase Alumni
  • March 4, 2020
Can you explain what you mean by "a block of code".. if you mean run successive API calls, then yes its possible.  Or is this javascript?  and is the trigger to push a button?

------------------------------
Mark Shnier (YQC)
Quick Base Solution Provider
Your Quick Base Coach
http://QuickBaseCoach.com
mark.shnier@gmail.com
------------------------------

Forum|alt.badge.img+15
  • Quickbase Alumni
  • March 5, 2020
Paul,

  • Build the parameters you need to use in the formula
  • Build a number of URL statements as variables with the parameters you need
  • Build a logic layer, that will determine which URL the user can execute.  
  • Create the User Interface for them to execute

// Parameters
var text Token ="abcdefghijklmnopqrstuv";
var text IMGButton  =     "<img src=https://images.quickbase.com/si/48/045-lock.png>"; 

// URLs
var text URLOne= 
  URLRoot() & "db/" & Dbid() & "?a=API_AddRecord&AppToken=" &   $Token &
 
 "&_fid_XX=" & URLEncode ([Record ID#]);

var text URLTwo =
var text URLAPIAdd =
  URLRoot() & "db/" & Dbid() & "?a=API_AddRecord&AppToken=" &   $Token &
 
  "&_fid_XX=" & URLEncode ([Record ID#]) &
   "&_fid_XY=" & URLEncode ([XY])&
   "&_fid_XZ=" & URLEncode ([XZ]);

and so on

// Logic

var text URLRun = If (
        [Rule One]= True, $URLOne,
        [Rule Two]= True, $URLTwo,
      and so on  )

// UI
<a href=\"javascript:" & "$.get('" & $URLRun  & "', function(){" & "location.reload();" & "});" & "void(0);\">" & $IMGButton & "</a>"


------------------------------
Don Larson
Paasporter
Westlake OH
------------------------------