Select new item in a Master detail

Hello, I have a simple master detail with a TemplateGrid and a dataview. When I create a new item in the template grid I want it to be selected and displayed in the dataview - how do I accomplish this? Thanks :) Fredrik
2 answers

I see 2 possibilities to achieve the desired functionality,

The first is dirty, what you basically do is set your template grid to select the first item. You add a order attribute to your entity with autonumber or date or what you choose and you order your template grid on this attribute. Then when creating a new object you close the page and you open it again. Once you use this mindset there are several options, but off course this limits you with sorting etcetera.

Another option is more clean but also takes more time. For this option you create a non persistent item which you connect to your entity(In my example the entity Employee) and the session object:

Next you create a microflow which retrieves the non persitent item if it exists(by Currentsession/EmployeeSelected_Session and then takes the first item with the Head List Operaiont) or creates(GetOrCreate) it when it doesn't exists and connects it to the currentsession. This microflow is the basis of your other microflows and the datasource to your dataview object on the page.

Then create a microflow to select your entity, add your entity as parameter and use the created microflow to select or create the non persistent item, then change the object and connect it to both your entity and the current session:


Then for creating a new item create a microflow which calls the above microflow with the newly created entity as paramter. 

Then for selecting in the template grid, instead of using the built in select functionality, you create functionality to call a microflow. In my case I used a simple button object but you there are many ways to go here so I leave that up to you. When clicking on it you call the microflow with the select functionality.

The only thing left to do is to present the selected object in a dataview. You create a dataview with the GetOrCreate microflow as datasource:

And the result:


Set your data source of the data grid to "Listen to widget" and the target is your tempalte grid.