How can I put a minus and plus button on my inventory dashboard that allows users to change a numeric value each time the button is clicked?

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

This is for an inventory management app.  Currently, we must click on the item and change manually change the inventory count by typing the new number.  We'd prefer to have a simple + and - button on each row that will save us time and be more accurate.

Photo of Jason

Jason

  • 0 Points

Posted 3 years ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,348 Points 50k badge 2x thumb
No problem to make a formula URL button to have as a report column.

Make a formula URL button with the following formula

urlroot() & "db/" & dbid() & ?act=API_EditRecord&rid=" &ToText([Record ID#])
& "&_fid_99=" & ToText([My Inventory Qty field]+1)

You will need to locate the field ID number for the field which holds the Qty. change the 99 to that number. In the field properties, you get to assign a label to the button so this code is hidden from the user.

Once we get this working, there is a way to change the color of the button, so the up and down buttons are different colors.
Photo of Jason

Jason

  • 0 Points
Thanks for your help.  I'm missing something.  I get a syntax error: Formula syntax error

Expected a valid expression after the "&"


urlroot() & "db/" & dbid() &   ?act=API_EditRecord&rid=" &ToText([Record ID])
& "&_fid_10=" & ToText([My Inventory Qty field]+1)
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,348 Points 50k badge 2x thumb
I was missing a " after that first &

urlroot() & "db/" & dbid() &   "?act=API_EditRecord&rid=" &ToText([Record ID])
& "&_fid_10=" & ToText([My Inventory Qty field]+1)

Also note that it is unlikely that you have a field called [My Inventory Qty field].  You will need to put in the field name for your field which now holds the Qty.
Photo of Jason

Jason

  • 0 Points
Excellent, one step closer now! I get this message now: This XML file does not appear to have any style information associated with it. The document tree is shown below.

<qdbapi>
<action>API_EditRecord</action>
<errcode>24</errcode>
<errtext>Invalid Application Token</errtext>
<errdetail>An Application Token must be supplied.</errdetail>
</qdbapi>
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,348 Points 50k badge 2x thumb
Can you do 2 things for me.

Can you go to Settings for the application, and then to App Properties and then uncheck the box for require Application Tokens.

Then can you post you formula and I will make the required adjustment.
Photo of Jason

Jason

  • 0 Points
All done.  Thanks, by the way
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,348 Points 50k badge 2x thumb
We are not done yet.  can you post your formula so I can make the change so that it will refresh the page.
Photo of Jason

Jason

  • 0 Points
URLRoot() & "db/" & Dbid() &   "?act=API_EditRecord&rid=" &ToText([Record ID#])
& "&_fid_10=" & ToText([Current Inventory]+1)
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,348 Points 50k badge 2x thumb
OK, change the formula to be this exact code



var text URL = URLRoot() & "db/" & Dbid() &   "?act=API_EditRecord&rid=" &ToText([Record ID#])
& "&_fid_10=" & ToText([Current Inventory]+1);

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

Jason

  • 0 Points
Awesome.  That worked.  To make a minus button field I just change to "-1", correct?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,348 Points 50k badge 2x thumb
Indeed
Photo of Jason

Jason

  • 0 Points
Great!  How do I make it look like a button? :)
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,348 Points 50k badge 2x thumb
On the field properties, there is a check box to make it show as a button.
Photo of Jason

Jason

  • 0 Points
Also, do I need to go back and require API key now for security?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,348 Points 50k badge 2x thumb
I personally do not feel it is necessary, but that is up to you.  You can read about Application Token in the help manual.  If you want to enable them, then you need to go to that settings page again and "manage Application tokens.

You would thgen create one and copy it and then insert a line of code like

& "&apptoken=swehjlfwjlfwlswdnksbakb"

so it would look like this


var text URL = URLRoot() & "db/" & Dbid() &   "?act=API_EditRecord&rid=" &ToText([Record ID#])
& "&apptoken=swehjlfwjlfwlswdnksbakb"
& "&_fid_10=" & ToText([Current Inventory]+1);

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

Jason

  • 0 Points
Great - thanks.  I'll hold off on adding that for now.  I'm all set.  Thank you!!!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,348 Points 50k badge 2x thumb
You must have one heck of a long button now!  Filed Properties lets you set the button words like
Add One to Inventory
Photo of Jason

Jason

  • 0 Points
It's adjusted now to "ADD" / "SUBTRACT" - it's awesome!  Thank you for helping me!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,348 Points 50k badge 2x thumb
:)  a happy ending to the story.