Commit the objects after clicking the final Submit Button

1
Hi I have a FAQ creation form, where the questions can be added through a PopUp screen which will prompt the Question text and Solution Type (MCQ, Textual, etc.).  The Domain Model for this goes like: QuestionBank <-1---------*- Question   Currently I have added an Add Button which is calling a microflow to Commit Object for each Question, but if the user even closes the page, the questions will be persisted, and also cannot apply a microflow for page close event. Is there any way, all the questions can only be committed with a single Submit Button?    Add Question Screen:   Questions List: 
asked
4 answers
2

Have you tried not committing your Question objects from the popup?

You could then create a Submit button on the parent page that calls a microflow. In this microflow you could retrieve the Question objects by association from the parent page’s QuestionBank object and then commit this list of retrieved objects. 

Hope this helps.

answered
1

Hi Tushar,

 

Hide the close button which is getting displayed in form using css property display:none;

 

Add custom close button to your form which calls the microflow to delete the objects whose isSubmitted attribute is false on form close.

 

In your entity have two boolean attributes, isAdded and isSubmitted

 

Update isSaved attribute to true while committing objects on click of add button.

 

Update isSubmitted button attribute to true on click of submit for all question objects. [You need to retrieve all objects from database and iterate it using loop].

 

 

answered
0

Hi Tushar,

 

You can use non-persistable entity for the new form and question popup with the similar structure as Question. When the user clicks on the submit button, the same non-persistable data can be added to actual persistable entity using Microflow and commit.

 

answered
0

Hi Tushar,

 

Work with Persistent Entities in Master Detail approach can be trick.

You have to keep in mind that Mendix ORM allows you to persist children without parent (We don’t have FK constraint in mendix – just association tables / entities )

 

SO, to work with Master/Detail, you may opt to just SAVE all – Main entity with some states (draft, active, inactive).

 

Now, working with Transient Objects (Entities not persisted) you have to Customize some actions like:

- Cancel button for children – should’t call cancel changes, instead, just Close popup forms. 

- Save buttons for children – should’t call commit, just validates and close popups

- Popup Close action – call action button “cancel” that will just close the form without cancel

- Save button for Main – this should commit Main entity and children list

 

Its doable, but, you may opt to use a State Machine approach or Non Persistent Entities (than clone / change the content to Persist ones)

 

Best regards

 

 

answered