Application Variable

  • 1
  • 1
  • Question
  • Updated 11 months ago
  • Answered
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?
Photo of Steven

Steven

  • 112 Points 100 badge 2x thumb

Posted 11 months ago

  • 1
  • 1
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.
Photo of Steven

Steven

  • 112 Points 100 badge 2x thumb
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.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,436 Points 50k badge 2x thumb
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?
Photo of Steven

Steven

  • 112 Points 100 badge 2x thumb
Pulled.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,522 Points 20k badge 2x thumb
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.
Photo of Steven

Steven

  • 112 Points 100 badge 2x thumb
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!  
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,522 Points 20k badge 2x thumb
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.
Photo of Steven

Steven

  • 112 Points 100 badge 2x thumb
You are correct....  I misread your response.  I thought it was on an external server.  That makes even more sense...  
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.
Photo of Steven

Steven

  • 112 Points 100 badge 2x thumb
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.
Photo of Steven

Steven

  • 112 Points 100 badge 2x thumb
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.