Forum Discussion

PaulPeterson1's avatar
PaulPeterson1
Qrew Assistant Captain
5 years ago

Execute a block of code in an IF Statement

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
------------------------------

7 Replies

  • DonLarson's avatar
    DonLarson
    Qrew Commander
    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
    ------------------------------
  • 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
    ------------------------------
    • PaulPeterson1's avatar
      PaulPeterson1
      Qrew Assistant Captain
      I'm trying to update multiple fields inside of an If statement.

      ------------------------------
      Paul Peterson
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend
        Can you say in words an example of the logic and I can suggest the code syntax for a URL formula button.

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