Discussions

 View Only
  • 1.  Execute a block of code in an IF Statement

    Posted 03-04-2020 14:09

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


  • 2.  RE: Execute a block of code in an IF Statement

    Posted 03-04-2020 14:12
    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
    ------------------------------



  • 3.  RE: Execute a block of code in an IF Statement

    Posted 03-04-2020 14:19
    I'm trying to update multiple fields inside of an If statement.

    ------------------------------
    Paul Peterson
    ------------------------------



  • 4.  RE: Execute a block of code in an IF Statement

    Posted 03-04-2020 14:24
    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
    ------------------------------



  • 5.  RE: Execute a block of code in an IF Statement

    Posted 03-04-2020 14:40
    One of the situations I am working with involves changing the text in a status field and adding a date in a related field when a condition in another field is met.

    ------------------------------
    Paul Peterson
    ------------------------------



  • 6.  RE: Execute a block of code in an IF Statement

    Posted 03-04-2020 14:41
    Edited by Evan Martinez 03-05-2020 09:45
    I was hoping to use as a time clock for our employees. 





  • 7.  RE: Execute a block of code in an IF Statement

    Posted 03-04-2020 18:06
    Kind of a general question to answer specifically.  But certainly one can create URL formula buttons to update multiple fields on a record and then land the user somewhere.

    Choices for leaning the syntax would be to
    download Kirk Trachy's Magic Buttons app from the Exchange,
    Downloading my app in the Exchange called URL Formuals for Dummies,
    using Automatons, 
    or else contacting ke for some one on one consulting assistance to build a URL formula button for you and show you how it was done.

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



  • 8.  RE: Execute a block of code in an IF Statement

    Posted 03-05-2020 07:20
    Edited by Don Larson 03-05-2020 12:02
    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
    ------------------------------