How to prompt the user if the sum of specified fields is not equal to 100% ?

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • In Progress
We want to include some automatic checking of date entry errors, and in one of our apps we need to have the sum of several fields that the user enters total to 100%.  What are some efficient ways to prompt the user for corrections when the total is incorrect?  I guess we could use "Dynamic Rules" to throw up a custom error message under those conditions, but we would rather require the user to get that total correct before they save that record.

I feel certain we are not the first or only customer to need this feature...
Photo of wlp

wlp

  • 142 Points 100 badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,352 Points 20k badge 2x thumb
Just ask the user for two out of three inputs and calculate the third as demonstrated in this demo:

Meatloaf ~ Two Out Of Three Ain't Bad ~ Add New Record

https://haversineconsulting.quickbase.com/db/bm5h58ry3

Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=603

(Edited)
Photo of wlp

wlp

  • 142 Points 100 badge 2x thumb
"Hot patootie – bless my soul" this might work for us.  Did you build this with simple calculated fields, or within Dynamic Rules? 

(I have a limited view of this demo app and don't see any way to grab the administrator view.)
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,352 Points 20k badge 2x thumb
>don't see any way to grab the administrator view

I have hundreds of public demos available and it would be impossible to make any of them available to everyone on the internet as an administrator. A lot of my answers and demos are crafted in a manner that addresses the fact that they are public and I don't want to have to maintain them constantly so sometimes I answer a slightly different questions than what is asked. But rest assured every single well formed question in this forum has an answer with a positive outcome. The hardest part for me in answering a question is figuring out what the heck the person is asking (not the case here) and of course coming up with a good attention grabbing gimmick that will induce readers to reflect on my ever so subtle subliminal messages.

>Did you build this with simple calculated fields, or within Dynamic Rules?  

No. I use the standard IOL technique documented in the pastie which uses a code page containing script. I would also add that I just put some random priority logic in the script not necessary the logic you would require. It would be a simple matter to implement other logic, limit the precision of percentages or prevent negative number etc. 

With the passage of time the QuickBase Singularity has arrived. We are converged and everything is now possible with QuickBase (using script).
(Edited)
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,352 Points 20k badge 2x thumb
>Did you build this with simple calculated fields, or within Dynamic Rules?  

BTW, Mark is probably working out a native solution as we speak. He likes to achieve native parity with script - try as he will.
(Edited)
Photo of wlp

wlp

  • 142 Points 100 badge 2x thumb
Sorry Dan, I was so distracted by your Meatloaf graphic that I missed the Pastie Database link.  I have now made my way back to that and see the script you used for this quickie demo.  Alas, it is beyond my ability.  (I use Quick Base to avoid writing code whenever possible.)
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,166 Points 50k badge 2x thumb
One solution is to have the last field be a formula field equal to 1 - the sum of the other fields. Then it will always total to 100%. That sound like your best solution.

The other method is to have two messages controlled by an IF statement. There can be a red message saying the total and saying it does not add to 100, and a green message saying Totaks OK.

Let me know if you need help with the color formula.
Photo of wlp

wlp

  • 142 Points 100 badge 2x thumb
 Thanks, Coach.  I will explore these options.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,352 Points 20k badge 2x thumb
How about just converting QuickBase's inputs to sliders (ie <input type=range>):



A Plate Full Of Sliders ~ Add New Record

https://haversineconsulting.quickbase.com/db/bm5k6564x?a=nwr

Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=606



Notes:

(1) I only implemented this feature for new records. Simple to extend for edit records.

(2) The code could be improved but I was short time and needed to make a quick road trip to White Castle.
(Edited)
Photo of wlp

wlp

  • 142 Points 100 badge 2x thumb
This is impressive, but too twiddly to throw in the user's workflow.  I'm looking for simple, vanilla error-checking on their totals.  I wouldn't want to build a custom GUI control.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,352 Points 20k badge 2x thumb
Suit youself. But this code does not really build a custom GUI control. Rather it simply changes the type property on the input from "text" to "range" which is a standard feature of HTML5 and availabe for years in all modern browsers.

If you look at this problem in isolation you might come to the conclusion it is "twiddly" as you say. But when you look at the problem of missing features in QuickBase more holistically you will find that there are many more problems that can be solved with a tiny amount of script in a similar fashion. So from my perspective it is worth solving every problem with script for which there is no native feature hardcoded into the product.

Just don't accept the excuse that it can' be done natively or quite frankly that such-and-such a feature isn't in the product development pipeline. All the Web technologies have matured enormously from the time when you formed the opinion that asking for changes and enhancements have to go through committees and are risky and costly to implement.
Photo of wlp

wlp

  • 142 Points 100 badge 2x thumb
Your point is well-taken, Dan.  But remember that part of the Quick Base pitch is that teams can quickly build most of their applications "without writing code".  If I start presenting script macros as the solution to routine problems, that "no coding required" value disappears.  My current clients have no scripting skills and want to manage their applications without paying for those skills.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,352 Points 20k badge 2x thumb
But the "no code" / "low code" thing is just a marketing pitch. The first thing you have to do after swallowing that ipill s to write QuickBase formula (which is coding) which can be extremely lengthy and complicate.
Photo of wlp

wlp

  • 142 Points 100 badge 2x thumb
Well many users do find the click-and-drag Quick Base formulas more intuitive than scripting.  And "do it yourself" is more than a marketing pitch -- its a real value than even teams with smaller budgets can appreciate.

But I do think your quote is the most important thing I have ever read on these community pages:

"With the passage of time the QuickBase Singularity has arrived. We are converged and everything is now possible with QuickBase (using script)."
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,322 Points 20k badge 2x thumb
>Well many users do find the click-and-drag Quick Base formulas more intuitive than scripting.

Maybe so but the cold hard reality is that without script solutions you would be hitting a brick wall with no options or workarounds if you only availed youself of native features. Every well formed question asked in the forum has a quick and short solution with script whereas not so much if you rely exclusively on native features. Javascript has taken over the world.

Atwood's Law
Any application that can be written in JavaScript, will eventually be written in JavaScript
https://en.m.wikipedia.org/wiki/Jeff_...