Forum Discussion
8 Replies
- _anomDiebolt_Qrew EliteThis is an excellent and timely question!
In a nutshell the Hylo Technique is a general technique for placing a button on a parent record which when clicked will add a set of child records initialized according to your specific needs. A typical use case might be to add a set of child tasks with fields initialized to specific dates, counters or names but the technique is so generic it could accommodate a lot of other possibilities and custom business logic.
Why is it called the Hylo Technique? Well Hylo is short for Hylomorphism a concept drawn from Category Theory and probably one of the most abstract areas of modern mathematics. What I love about QuickBase is that is a great platform for learning about Category Theory and other super abstract mathematical concepts. Heck if QuickBase marketing is going to push this Low Code Citizen Developer meme I am going to promote Category Theory - we have got to have some balance and clarity in our QuickBase work since math is everywhere including within QuickBase:
Numb3rs Scene: Everything is numbers, Math is everywhere
https://www.youtube.com/watch?v=vFRTgr7MfWw
So this is how I will cast the problem: Let's you have set of parameters say {Base Date, Frequency, Number} associated with some parent record and you want to automatically create a set of child records and initialize the child records based on these parameters. For example if the Base Date was "6/9/2016", the Frequency was "Weekly" and Number was 5, and the Parent [Record ID#] was 56 we would want to create child records based on this string of CSV data:
[Date], [Related Parent]
6/9/2016, 56
6/16/2016, 56
6/23/2016, 56
6/30/2016, 56
7/7/2016, 56
You can think of this as a two step process:
First, let's generate a list of data for the child records from the parameters basedate, frequency and number. Generating a list from a set of parameters is called an unfold or anamorphism in Category Theory.
Second, let's take our list of data for the child records and condense it into a single string representing the CSV data we need to import to create the child records (using API_ImportFromCSV). Generating a single value from a list is called a fold or catamorphism in Category Theory.
When you perform an unfold followed by a fold this process is called a Hylomorphism in Category Theory. So now you know that when you are want to create a set of child records from a button push based on a set of parameters associated with the parent record you are basically performing a Hylomorphism. What could be more simple?
So here is the demo I promised:
Hylo[morphism] Technique
https://haversineconsulting.quickbase.com/db/bkw2ff3e3?a=q&qid=1
Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=511
Notes:
1) The demo has been set up so you can create parent and child records. Bear in mind that other users may have created records before or during your visit to the application.
2) Clicking the "Sans Dialog" button will create records according to the field values in the parent record. Clicking the "With Dialog" button will ignore the field values inthe record and prompt you to enter similar parameters through a popup dialog.
3) Using the "Sans Dialog" button field values are passed to the moduleParents.js script using data attributes.
4) Using the "With Dialog" button parameters (basedate, frequency, number) are solicited through a jQueryUI Dialog widget. Further, the basedate used the jQueryUI Datepicker to select a date.
5) This demo uses the AMD module for momentjs to perform date calculations. QuickBase has already declared this is an AMD module so all we do is requre it in the script.
6) With either button after the child records are created the script will redirect to a view of the parent record with an embedded list of child records. Your newly create child records will be displayed among the records of the embedded report.
7) This script is quite general and could be modified in many ways to implement other requirements and business logic.
8) In case you are wondering a fold followed by an unfold is called a metamorphism in Category theory. - JonathanHeuerQrew CadetCrazy cool, Dan. Is there a way to make some/all of the fields in the dialog box required (perhaps with helpful user messaging)?
- _anomDiebolt_Qrew Elite>Crazy cool,
Yes it was a genius idea to counter QuickBase's Marketing team promotion of "low code" and "citizen developer" branding with my "all code" and "category theory" memes.
> Is there a way to make some/all of the fields in the dialog box required
Yes that is possible. It is just HTML, CSS and JavaScript so you can pretty do anything you want.
Anyway I am hard at work preparing a half dozen Empower 2017 presentations so I can get a free ticket. My first presentation is entitled "Citizen Developer Stubs Toe - PROJECT CANCELED" - it is a cautionary tale. - GauravSharma3Qrew CommanderAwesome.. I love this technique.
Looking forward to implementing this technique for one of our scenarios.
Thank you for working out.:) - TateForgeyQrew Assistant CaptainThis is just what I was looking for. I am a newbie to both in "iol" and javascript, but after some forum searching and trial in error I got an exact copy the demo to work in my app. Hooray!
Now I'm trying to customize this to my needs where 1) I don't need to increment a date, but just a number and 2) there are a couple other variables that would not appear on the parent, but I want to set in the dialog and pass to all the child records.
I feel like this would be easy, but I got no skills. Any ideas of where to start?- TateForgeyQrew Assistant CaptainAfter another day of staring at this blankly I have worked this out.
For any other unindoctrinated that may stumble on this, I made the mistake of thinking that my lack of JavaScript was the issue, but really the key was understanding how the Quick Base API_ImportFromCSV works and that the var fidsChilds defined at the top is used in the clist portion near the bottom. Once you understand how that works you can include whatever fields you want in the dialog table, header variable and in the body so you can pass it along.
- GauravSharma3Qrew Commander
Hi Dan,
I hope you are doing well.Just a quick query, we can only create the child records in the view mode. Because, if I use this technique in the edit mode then, It does not work.
Any thoughts here?
Stay safe and healthy.
Thanks,
Gaurav
------------------------------
Gaurav Sharma
Senior Business Applications Developer
Elevate Services India Pvt. Ltd
Gurgaon
8826743679
------------------------------- MarkShnier__You
Qrew Legend
Alas, Dan has dropped out of sight for a few years now.
------------------------------
Mark Shnier (YQC)
Quick Base Solution Provider
Your Quick Base Coach
http://QuickBaseCoach.com
mark.shnier@gmail.com
------------------------------