Discussions

Expand all | Collapse all

Application Variable

  • 1.  Application Variable

    Posted 12-20-2017 17:50
    Have a formula I would like in all 75 tables in my application.  I have tried making it an application variable, but when added to the tables, it only interprets the formula as text and does not display the result of the formula.  Is there an easy way to accomplish this without linking all 75 tables to a "settings/default" table that has the formula in it?


  • 2.  RE: Application Variable

    Posted 12-20-2017 18:20
    Just out of curiosity, what function does the formula serve where it would be practical on every application table. I'm just hoping to understand so I can venture a guess as to how to make this easier.


  • 3.  RE: Application Variable

    Posted 12-20-2017 18:36
    The function is to create a token for each table adding a level of security when writing or pulling data from that table via API.


  • 4.  RE: Application Variable

    Posted 12-20-2017 18:25
    A thought is that you can set the value of an application variable with an API.  API_SetDBvar

    Maybe push a button each day to set the updated value?


  • 5.  RE: Application Variable

    Posted 12-20-2017 18:42
    We're getting closer with this, but the variable is a token for us and would need to change at the exact time another site is changing that variable.  It works much like a handshake.


  • 6.  RE: Application Variable

    Posted 12-20-2017 18:47
    I assume the other site is issuing some type of token that is valid for a certain amount of time and you need to port that token over to QuickBase so you can make URL calls to that external service. Is this correct?

    By what mechanism does QuickBase become aware that the token issued from the other site has been issued or changed? Does the other site post to QuickBase or does Quick Base pull the token from the other site?


  • 7.  RE: Application Variable

    Posted 12-20-2017 18:51
    Yes!  The token changes with time stamps.  The other site looks at the token in QB and then checks its own database for the same token (also the same formula).


  • 8.  RE: Application Variable

    Posted 12-20-2017 18:58
    >The other site looks at the token in QB and then checks its own database for the same token (also the same formula).

    This describes how the token is validated and used one it is know to exist (valid or not). That isn't what I asked. How does QuickBase become aware of a newly issued token or a changed token? Is the token pushed or pulled from the other site?


  • 9.  RE: Application Variable

    Posted 12-20-2017 19:00
    Pulled.


  • 10.  RE: Application Variable

    Posted 12-20-2017 19:09
    So you have to arrange for JavaScript in a code page to make a request to the server issuing the token. When the response arrives you parse out the token and save it in a QuickBase application variable using API_SetDBvar. Once a fresh token is saved in an application variable your URL formulas in all the tables can reference it in that various URLs that access the external service.

    I don't know what external service you are using so I can't provide any additional advice. There will certainly be more steps to get the token issued as you probably have to log into that service before even requesting for a token.


  • 11.  RE: Application Variable

    Posted 12-20-2017 19:18
    Interesting....  so, every time we make a call to QB, FIRST set the DBVar and THEN check the token with the call...  Definitely, doable...  Then I am only changing the token formula on one issuing server.  Thank you so much for your help!  


  • 12.  RE: Application Variable

    Posted 12-20-2017 19:28
    I think you understand what I said but I don't understand your summary:

     "so, every time we make a call to QB, FIRST set the DBVar and THEN check the token with the call."

    You seem to be using "we" as representing the external server.

    The context above seems to be reversed from what I said. To be explicit: Script in a QuickBase code page makes a request to the external server for a token and caches  the token in a user defined variable which formulas URLs can then use to make subsequent resource requests to the external for the period of time the token is valid.


  • 13.  RE: Application Variable

    Posted 12-20-2017 19:36
    You are correct....  I misread your response.  I thought it was on an external server.  That makes even more sense...  


  • 14.  RE: Application Variable

    Posted 12-20-2017 18:33
    Application Variables always present themselves as "Text", so depending on the result the formula is meant to display, you would need to indicate the format in the Formula field you're using to call upon that app variable by name - for the following example we'll say your app variable name is "Variable"

    if you were to want to use this app wide variable on a form, you would need to use a formula type field, and in that formula you need to indicate the format the variable should result in, followed by the the variable name enclosed in brackets, just as you would when referencing any other field on that form.
    Ex. ToNumber([Variable])
    or ToText([Variable])
    or ToDate([Variable]) etc.

    Hope this helps, although I'm still really curious about your specific use-case for the app-wide formula variable.


  • 15.  RE: Application Variable

    Posted 12-20-2017 18:40
    So here is the formula I want in my app variable:

    ToText(Floor(Year(Today())/Day(Today())) & ToText(Day(Today()))&"9654"&ToText(Month(Today()))&"3546w")

    Ultimately, this: 100209654123546w would be displayed in a field in the table.  I want to be able to change that formula globally.  I suppose I could create variables for the parts in quotes and then change those, but would prefer to have the ability to change the whole formula for the entire application and all tables in one place.


  • 16.  RE: Application Variable

    Posted 12-20-2017 20:54
    Thank you to all respondents.  Please consider this question resolved.  Dan, thanks again for your guidance.  We will probably end up doing a variation of your suggestion.