Forum Discussion

olivermah's avatar
olivermah
Qrew Assistant Captain
7 years ago

URL button to trigger Automation

I've created a URL button that changes a check box field which in turn triggers an Automation to change values in certain fields.  

Everything works fine, however, I've now put these buttons into a report so that the users can just click the button to make it all happen.  This works fine as well

Button get clicked - check box updates as checked

the problem is the values don't automatically change until I refresh the page. Is it possible for the values change when the button is pushed?  Just like the check box updates?
  • SuryaExpert's avatar
    SuryaExpert
    Qrew Assistant Captain
    I have noticed that too. Automations, Actions and Webhooks do not provide instant gratification, unfortunately.You have to either wait for one or two more seconds AND refresh the screen one more time.

  • Oliver,
    I see from your posts you are making great progress in learning Quick Base.  if you want to get the page to refresh, you will need to move from "no code" (Automations and Actions") to "Low Code" (URL formula buttons.)

    I have put an app in the Exchange called URL Formuals for Dummies which explains some of what you would need to know.  I suggest downloading that to read up on how they work.

    Here is an example of updating a few fields on a record and refreshing the page


    var text URL= URLRoot() & "db/" & [_DBID_TABLE_1] & "?act=API_EditRecord"
    & "&rid=" & URLEncode ([Record ID#])
    & "&_fid_7=" & URLEncode ([Status])
    & "&_fid_8=1" 
    & "&_fid_9="  & URLEncode("the rain in Spain falls mainly in the plain")
    & "&apptoken=" & "XXXXxxxx";


    "javascript:" &
    "$.get('" & 
    $URL & 
    "',function(){" &
    "location.reload(true);" &
    "});" 
    & "void(0);"



    The code above starts with a formula variable called URL.  The formula URL text lays out the edit, specifying which record to be edited, and then it puts the value of the field [Status] into field ID 7 and then set the checkbox field ID 7 to be checked and puts a phrase into fid 8.

    Then the javascript stuff below executes that URL formula and refreshes the page.

    The app token will be required if you still have your app's Advanced Properties to require application tokens.  Many developers turn that requirement off, but that is your call 

    You need to URLEncode where the text might have spaces or another characters which are not permitted in a URL.

    Give it a try.


  • olivermah's avatar
    olivermah
    Qrew Assistant Captain
    Thanks so much for your kind feedback - my current code running the button shows like this its just missing 1 portion, I assume that would be my problem - its just missing the last line which your has and mine doesn't: &"void(0);"

    var text URL = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Record ID#]

    & "&_fid_354=" & URLEncode("true");


    "javascript:" &
    "$.get('" & 
    $URL & 
    "',function(){" &
    "location.reload(true);" &
    "});"

  • Did you try it like this?

    "javascript:" &
    "$.get('" & 
    $URL & 
    "',function(){" &
    "location.reload(true);" &
    "});" 
    & "void(0);"
  • olivermah's avatar
    olivermah
    Qrew Assistant Captain
    yeah I think it might be because the checkbox triggers an automation to change the values.  the code for the button works well and the checkbox checks upon the button click but you have to refresh the page again in order for the values to change. 
  • That code in a formula URL button will do the update and refresh the page.  There is no need to refresh the page manually.  The Automation should be turned off if you are using this method.
  • olivermah's avatar
    olivermah
    Qrew Assistant Captain
    all sorted out - Thanks again for your help.  My brain was stuck on the automation and couldn't get out of that mindset.  I disabled them and they worked out.