Discussions

Expand all | Collapse all

A formula URL button that adds +1 to a numeric field

Xavier Fan08-13-2014 14:56

Archive User12-06-2016 17:31

  • 1.  A formula URL button that adds +1 to a numeric field

    Posted 08-12-2014 14:57

    I need help creating a formula URL button. I have an issues/suggestions table. If a user is also having the same issue that has already been submitted I basically want to create a me too or +1 button. When the button is pushed is adds one to the value in the [Number of Votes] field. Thanks in advance for any help!



  • 2.  RE: A formula URL button that adds +1 to a numeric field

    Posted 08-13-2014 02:17
    In your Issues table:

    Numeric field: [Number of Votes] (set the default value to 0, or 1 - as you prefer)

    Formula Numeric field: [Next Number of Votes] (formula = [Number of Votes] + 1 )

    Formula URL field: [Me Too]

    Formula:

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

    & "&apptoken=XXXXXX"

    & "&_fid_YYYY=" & [Next Number of Votes];

    var text URLTwo = URLRoot() &"db/" & Dbid() & "?a=dr&rid=" & [Record ID#];

    $URLOne & "&rdr=" & URLEncode($URLTwo)

    Notes:- replace "XXXXXX" with your application token, YYYY with the field ID of your [Number of Votes] field- URLOne edits the record that the button is sitting on, overwriting the value in [Number of Votes] with the value in [Next Number of Votes] (i.e. fills it in with [Number of Votes] + 1)- URLTwo redirects to the View version of the same record- string URLOne and URLTwo together - and when you press the button, the [Number of Votes] increments, and the page refreshes to the View version of the record


  • 3.  RE: A formula URL button that adds +1 to a numeric field

    Posted 08-13-2014 14:09
    Thank you so much! Worked perfectly! I was close but a couple of things in my formula were off.


  • 4.  RE: A formula URL button that adds +1 to a numeric field

    Posted 08-13-2014 14:56
    Great - glad it worked for you!


  • 5.  RE: A formula URL button that adds +1 to a numeric field

    Posted 12-05-2016 18:02
    Sorry for reopening an old thread - this formula works great but is there anyway I could change the way the link displays to an image?  

    I tried based on the info from the post here: https://quickbase-community.intuit.com/questions/1453788-how-do-you-make-a-forumula-text-button-in-order-to-navigate-to-another-form-with-the-same-record
    - but this just messes up the Formula syntax.

    I would like the button to click on be a thumbs up icon. Is this possible?


  • 6.  RE: A formula URL button that adds +1 to a numeric field

    Posted 12-05-2016 18:32
    You'll have to supply the thumbs up icon - at a URL that is accessible by the users in your QuickBase app.

    Then:

    Create a new Formula URL field - called [Like Button]
    with the following formula:

    var Text LikeURL = ToText([Me Too]);
    var Text ImageURL = "https://images.quickbase.com/si/16/200-add.png";

    "<a href='" & $LikeURL & "'>" &
    "<img src='" & $ImageURL & "'>" &
    "</a>"

    This takes the URL from [Me Too], and puts in a HTML link around your image.

    You'll need to swap out the ImageURL value with your own image URL.


  • 7.  RE: A formula URL button that adds +1 to a numeric field

    Posted 12-06-2016 09:17
    hmm I just seem to get a> displayed when I do this so I think there is something not quite working - probably I missed something somewhere


  • 8.  RE: A formula URL button that adds +1 to a numeric field

    Posted 12-06-2016 16:02
    There are some tricky single quotes in there - make sure to copy the formula exactly.  You should only need to edit the LikeURL and ImageURL.  Get it working first, and then you can modify from there.


  • 9.  RE: A formula URL button that adds +1 to a numeric field

    Posted 12-06-2016 17:11
    Ah ok sorry - completely new to this. I left the end part unchanged i.e.

    "<a href='" & $LikeURL & "'>" &
    "<img src='" & $ImageURL & "'>" &
    "</a>"

    The only part I changed is the  ImageURL and the field as mine is called something else i.e. my final formula looks like this:

    var Text LikeURL = ToText([Upvote Record]);
    var Text ImageURL = "https://assets.quickbasecdn.net/res/73823-18/js/ckeditor-dev-4.5.8/plugins/smiley/images/thumbs_up.png";

    "<a href='" & $LikeURL & "'>" &
    "<img src='" & $ImageURL & "'>" &
    "</a>"

    While I was playing I added the Quickbase smiley image before I figure out where to host mine.

    So I need to change the $LikeURL and $ImageURL as well? I presumed these were defined by the previous lines, not sure what I would put here.

    Thanks for your help, its been great!


  • 10.  RE: A formula URL button that adds +1 to a numeric field

    Posted 12-06-2016 17:24
    You should only need to change the $LikeURL and $ImageURL.

    I just checked what you copied in - it worked for me.

    Let's check a couple of things:

    Did you create a NEW Formula Text field to put this formula in?  
    And checked "Allow some HTML tags to be inserted in the field"?

    If you had the same structure as my original example, your [Upvote Record] should be a Formula URL field.  

    This new Formula Text field would take that [Upvote Record], and use an image for the link.


  • 11.  RE: A formula URL button that adds +1 to a numeric field

    Posted 12-06-2016 17:30
    Aha - I created it as a new Formula URL field - thats fixed it! Brilliant thanks for all your help


  • 12.  RE: A formula URL button that adds +1 to a numeric field

    Posted 12-06-2016 17:31
    Great!  You're welcome.


  • 13.  RE: A formula URL button that adds +1 to a numeric field

    Posted 05-21-2019 15:57
    Wanted to breathe life back in the post 2 years later.  I have the above coding working perfectly, but I am curious to see if there is a way where the button/image can be clicked and the count recorded without going into the record


  • 14.  RE: A formula URL button that adds +1 to a numeric field

    Posted 05-21-2019 16:21
    Can you explain this

    "without going into the record".

    Are you asking if the button can be clicked to edit the record without needing to log into Quick Base?



  • 15.  RE: A formula URL button that adds +1 to a numeric field

    Posted 05-21-2019 16:27
    Thanks for the response!

    I am logged into Quick Base and on my respective "Enhancements" table in this case.  My "button" is an upvote button.  When I click on the upvote button, it edits the record, but then clicks into the record as well to see the deeper information.

    Ideally, I could click the upvote button causing the edit, yet keeping the User on that same view/report, without navigating into the record




  • 16.  RE: A formula URL button that adds +1 to a numeric field

    Posted 05-21-2019 17:16
    You can do this with a Formula - URL field. Make it appear as a button in the settings and add it to your report. Then when clicked on your report it will edit the associated record(whatever row in the report) and do whatever you want then reload the page and hopefully you should be at the same spot on the report.

    The post by Xavier Fan in there details how to do this. Better to link to a bunch of information than explain it here.

    https://community.quickbase.com/quickbase/topics/url-formula-to-edit-a-record-and-refresh-the-page

    I do something similar and I also wrap the whole thing in another condition so when the button is clicked once it cannot be done again on that record. It sounds like you want it to be clicked many times but this is an option for another time that you can use.