The Parent/Child feature with m-Power’s Data List with Web Form template (Display and Maintain Rows in Sky Theme) provides a popular way to work with data that has single header record that corresponds to one or many detail records. Sometimes when working with a parent record there may be type of child assignment that you would like to do at the same time. An example of this is found in the m-Power interface in several of the Menu & Security screens. When updating application users, you can assign multiple roles to the user as well. When doing this, it is actually writing records to a separate table. The User – Role relationship is a prime example of a parent/child, one-to-many type scenario. The same can be found on the Menu Options screen where you can assign a menu options to multiple user roles while configuring the menu option.
Being able to update a parent record and simultaneously add/delete a child record all from a single screen is what the Parent/Child Quick Add feature is for, and this documentation will cover how to use this feature in your parent/child maintainer setup. To implement, you’ll just need to have a pair of parent and child maintainer applications.
In the example that follows, I have a database table called ‘ARTICLES’ which lists out various articles that have been published. I have another database table called ‘CONTRIBUTIONS’ which has a hierarchal dependency to the ‘ARTICLES’ table, as ‘CONTRIBUTIONS’ lists out the various authors who have made a contribution to a single article. The field that identifies the contributing author(s) is the AUTHORID. It is these two tables that construct my parent/child relationship.
A third database table ‘AUTHORS’ exists that is not directly involved in the parent/child maintainers setup, but simply contains details about the author such as the name and email.
In the images that follow, my parent maintainer #10 is built over ARTICLES.
When ‘View Details’ is pressed, the child maintainer #20 that is built over CONTRIBUTIONS contains the contributions made by different authors to the parent article.
It is the Parent Maintainer where I’m going to implement the Quick Add functionality. In the m-Power interface, I’m going to edit said parent maintainer and select the ‘Actions and Info’ –> ‘Link Parent to Child’. In this modal window that appears, I’ll select the ‘Child Quick Add’ tab.
The options here are both required to be filled out, and are explained as follows:
- Child Quick Add Option List – The selected Option List Retrieval that will allow the user to quickly select child options from a dropdown list to add as child records
- Child Application Field – The field in the child maintainer application that will be written to when a user selects from the Option List Retrieval
In my case, I have an Option List retrieval #100 that I have pre-built over the AUTHORS table, which simply contains the Author ID and the Author Name fields. Because Author ID is the only column contained in the CONTRIBUTIONS table (that the child maintainer writes to) that appropriately identifies the author(s) who have contributed to the article, I made sure to configure my Option List retrieval dropdown to submit the Author ID value when an option is selected, while showing the corresponding Author Name to the user for convenience.
Once finished here, I’ll press ‘Save Child Link’ and recompile the parent maintainer with an HTML overwrite (note, specifically only the ‘Maintainer Form’ HTML page needs to be overwritten). After the recompile is finished, I will run the parent maintainer and press ‘Update’ (pencil icon) on any article record.
I can immediately see a tag review of all the child records (contributors) that have already been added to this parent record (article), those being John Richardson and Rick Hurckes. Should I click on the blue box with their name, this will delete their corresponding record from the child maintainer. On the flip side, I can use the ‘Add child record’ dropdown to quickly add myself (Matthew Espindola) as a contributing author to the article and m-Power will write the appropriate child record behind the scenes.
Note that child options are added or deleted instantaneously via an AJAX request, therefore it is not necessary to press ‘Accept’ on the parent maintainer form in order to use this Quick Add/Remove functionality.
Pressing ‘View Details’ back on table list page of the parent maintainer will show me the child records that were written behind the scenes. I can see I have been added appropriately, and m-Power has incremented the Contribution ID as well to the next available value.
Other General Notes
- Adding child records via the Quick Add feature is only accessible when updating the parent record. The functionality is not present when adding a parent record.
- The Quick Add feature is just making one-step maintainer calls to the child maintainer application. If field being written to is not a dimension field, then it is assumed that the child key is auto-sequence.