Forum Discussion
BasuB
7 years agoQrew Member
Has there been any update that will allow the count of multiple lines in a field.
- _anomDiebolt_7 years agoQrew EliteTry this text formula field with some HTML allowed:
"<img src onerror='this.outerHTML='" & [Words] & "'.split(/\\s+/).length'>"
See:
Old Techniques Not Discolsed ~ List All
https://haversineconsulting.quickbase.com/db/bm5f3b6ra?a=q&qid=1
I Just Got Reamed Out By The QuickBase Coordinating Council!!!!
https://community.quickbase.com/quickbase/topics/i-just-got-reamed-out-by-the-quickbase-coordinating... - QuickBaseCoachD7 years agoQrew CaptainDan, so that was impressive to a native guy like me.
Is that new that you can use non native syntax in a formula box with no IOL required? - _anomDiebolt_7 years agoQrew EliteThere is no IOL or code page needed for these types of formula.
But you realize of course that I am using my highly developed sense of humor to push for wider JavaScript adoption and eventual replacement of the formula language with JavaScript.
The mystery to me is why a native guy like you would be impressed with these new formulas because they are pretty odd to me and every other JavaScript developer. - _anomDiebolt_7 years agoQrew ElitePerhaps I should explain how that formula works:
"<img src onerror='this.outerHTML='" & [Words] & "'.split(/\\s+/).length'>"
Notes:
(1) The formula is a text formula field with some HTML allowed that synthesizes an <img>
(2) Because there is no src attribute value specified this generates a load error and the onerror handler is immediately invoked.
(3) Within the onerror handler "this" refers to the image object itself and this.outerHTML instructs the browser to replace the HTML nested within the <img> and the <img> itself to be replaced with the calculated value after the equal sign.
(4) The value after the equal sign is just the content of the [Words] field wrappend in backticks. Backticks are a new feature in JavaScript that allows you to build a string and perform interpolation (ie substitution) on tokens within the backtick quoted string. We are actually not doing any interpolation here but rather just using the backticks as a third type of quote character so that the [Words] field can itself contain both the single and double quote characters you are familiar with.
(5) Additionaly, once the backticked string is built we use a regular expression to split it on runs of whitespace characters to convert it into an array and grab its length
(6) The net results of all these operations is that a count of the number of words in the field [Words] is displayed as a number (without the <img> tag) in the appropriate cell of the form or report.
(7) You could probably create a couple of user defined variables (ie similar to [iol] and [/iol]) to hide some of the obscure formula details but I will probably not travel down that road as we are at the threshold of god mode (Service Workers) for QuickBase. This is precisely the route that was taken on Planet Claire during the 100 year period that proceeded their adoption of Service Workers with QuickBase. - BasuB7 years agoQrew MemberI will certainly try this but I was looking for a numeric formula field that I can use in summary reports. We have a multi-line text field where we list the names of users that we help with support ticket and would like to get a count of those for reporting purpose._
- _anomDiebolt_7 years agoQrew EliteThis is a workaround. Formulas of this type will display correctly without using a code page but their values cannot be used in other formulas or summary calculations.
If your ultimate goal is to include a word counting field in a summary report you will have to use a conventional formula such as Ken offered and accept the length of that formula and a maximum allowable count of say 10.
Towards your ultimate goal there is yet another workaround using script that could generate a custom summary report as you like but it would not involve using a native summary report. Everything is possible with script but there are practical obstacles to making script override QuickBase's hard-coded native features.
Ultimately a solution without workarounds has to come from QuickBase and the best suggestion I can give them is to ditch the formula language and adopt JavaScript as the primary was to calculate and string together workflow. If they adopt JavaScript we will no longer have to resort to obscure hacks like this. BTW, when I say ditch the formula language and adopt JavaScript I am overstating my case to drive a point home. QuickBase could easily continue hard-coding features into the product/interface which were just superficial overlays to some script for which a more advanced user might directly interact with for a more demanding or custom requirement. It took Planet Claire 100 years to come to these conclusions but eventually they realized the truth of what I am telling you.