Forum Discussion
_anomDiebolt_
Qrew Elite
>How do I extract out of a text field that reads "John Smith - Manager - jsmith@aol.com - 8555551212"
I am not sure how this relates to the original question that mentioned "multi select text field" but it is easy to parse the string you supply and send the parts to individual fields. Here is a demo:
Parse Once ~ Add New Record
https://haversineconsulting.quickbase.com/db/bn7925wrp?a=nwr
Just press the button Parse String and the components will be filled in.
Here is the button definition:
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=697
Notes:
(1) This example use a feature in JavaScript called destructuring which can greatly shorten your code. In a nutshell the array returned by splitting on the regular expression / - / is simply slotted into the input fields with fids = 6, 7, 8, and 9:
[_fid_6.value, _fid_7.value, _fid_8.value, _fid_9.value] = _fid_11.value.split(/ - /);
(2) In contract with a formula solution, the parsing of the [String] field is only done once at or near the time of initial data entry.
(3) This technique is quite generic - any string you have in QuickBase can be split into components using regular expressions. As a bonus there have been new features add to JavaScript's regular expression engine that allow parsing of Unicode string and the use of both look-ahead and look-behind patterns (this makes is simple to parse sub-strings within matching quotes, parentheses or even HTML tags).
I am not sure how this relates to the original question that mentioned "multi select text field" but it is easy to parse the string you supply and send the parts to individual fields. Here is a demo:
Parse Once ~ Add New Record
https://haversineconsulting.quickbase.com/db/bn7925wrp?a=nwr
Just press the button Parse String and the components will be filled in.
Here is the button definition:
"<a href=# class='Vibrant Success' onclick='[_fid_6.value,_fid_7.value,_fid_8.value,_fid_9.value]=_fid_11.value.split(/ - /);'>Parse String</a>"Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=697
Notes:
(1) This example use a feature in JavaScript called destructuring which can greatly shorten your code. In a nutshell the array returned by splitting on the regular expression / - / is simply slotted into the input fields with fids = 6, 7, 8, and 9:
[_fid_6.value, _fid_7.value, _fid_8.value, _fid_9.value] = _fid_11.value.split(/ - /);
(2) In contract with a formula solution, the parsing of the [String] field is only done once at or near the time of initial data entry.
(3) This technique is quite generic - any string you have in QuickBase can be split into components using regular expressions. As a bonus there have been new features add to JavaScript's regular expression engine that allow parsing of Unicode string and the use of both look-ahead and look-behind patterns (this makes is simple to parse sub-strings within matching quotes, parentheses or even HTML tags).
JoshuaSmith
6 years agoQrew Trainee
Thank you