78
Views
15
Comments
Solved
Master Detail Default value
Question

Hi Community,

Beginner and excited :)

I use the widget "Master detail" on a screen.

It's possible the fetch from my entity a default value for my "SelectedId" var?

Hope my question make sense!

Hi Sylvain,

I get the feeling that maybe your question is not entirely clear to everybody.  You are using the master detail widget, right ?

So on the left pane you get a list and on the right you show details of whatever item in the list from the left is selected.  Did you follow this explanation to build it ?  So when you first open the screen, the list shows up on the left, but nothing on the right, until user first makes a choice on the left, right ?

So if this is you set up, the only thing you want changed, is that one of the items on the left is "pre-selected" as it were, already showing those details on the right without the user having to do anything ?  

Let's say you want whatever item is retrieved as first item in the list to be pre-selected.  You will have to add some logic once the list returns.  That would be by adding an onAfterFetch event to the aggregate that retrieves the list.  

In this OnAfterFetch, just do whatever you do, when an item in the list is clicked to populate the detail.  If you followed that explanation, that would be an assign statement to set the local Id variable to the selected item (by default that is the first), followed by a refresh of the aggregate that retrieves the details based on that id.


See attached oml, since I want exactly the same to happen in the onAfterFetch as when user clicks an item, I just reused the ClickSelectedUser as the OnAfterFetch.


Good luck,

Dorine

DemoMasterDetail.oml

mvp_badge
MVP

Dorine Boudry wrote:

Hi Sylvain,

I get the feeling that maybe your question is not entirely clear to everybody.  You are using the master detail widget, right ?

So on the left pane you get a list and on the right you show details of whatever item in the list from the left is selected.  Did you follow this explanation to build it ?  So when you first open the screen, the list shows up on the left, but nothing on the right, until user first makes a choice on the left, right ?

So if this is you set up, the only thing you want changed, is that one of the items on the left is "pre-selected" as it were, already showing those details on the right without the user having to do anything ?  

Let's say you want whatever item is retrieved as first item in the list to be pre-selected.  You will have to add some logic once the list returns.  That would be by adding an onAfterFetch event to the aggregate that retrieves the list.  

In this OnAfterFetch, just do whatever you do, when an item in the list is clicked to populate the detail.  If you followed that explanation, that would be an assign statement to set the local Id variable to the selected item (by default that is the first), followed by a refresh of the aggregate that retrieves the details based on that id.


See attached oml, since I want exactly the same to happen in the onAfterFetch as when user clicks an item, I just reused the ClickSelectedUser as the OnAfterFetch.


Good luck,

Dorine

Hi Sylvain,

@Dorine IS right, i forget about that. you are using "Mater-Detail" UI widget.

hope @Dorine solution will help you. :-)



Regards

Rahul Sahu

Sylvain Lapointe

Dorine Boudry wrote:

Hi Sylvain,

I get the feeling that maybe your question is not entirely clear to everybody.  You are using the master detail widget, right ?

So on the left pane you get a list and on the right you show details of whatever item in the list from the left is selected.  Did you follow this explanation to build it ?  So when you first open the screen, the list shows up on the left, but nothing on the right, until user first makes a choice on the left, right ?

So if this is you set up, the only thing you want changed, is that one of the items on the left is "pre-selected" as it were, already showing those details on the right without the user having to do anything ?  

Let's say you want whatever item is retrieved as first item in the list to be pre-selected.  You will have to add some logic once the list returns.  That would be by adding an onAfterFetch event to the aggregate that retrieves the list.  

In this OnAfterFetch, just do whatever you do, when an item in the list is clicked to populate the detail.  If you followed that explanation, that would be an assign statement to set the local Id variable to the selected item (by default that is the first), followed by a refresh of the aggregate that retrieves the details based on that id.


See attached oml, since I want exactly the same to happen in the onAfterFetch as when user clicks an item, I just reused the ClickSelectedUser as the OnAfterFetch.


Good luck,

Dorine

Hi @Dorine

It's exactly my need.  Sorry for my poor explanation, english is not my primary language ;)


Thank you all for your help, this community rocks ! 

Best regards,

SL 

mvp_badge
MVP

Hello Sylvain Lapointe,

Welcome to Outsystems World :)

Yes, it's possible! Just need to change the Data Type property of the var to your <Entity> Identifier and adapt the code to that change. Can you do it or need some help?

Please see the example below:


BR,

Luis

Sylvain Lapointe

Luís Cardoso wrote:

Hello Sylvain Lapointe,

Welcome to Outsystems World :)

Yes, it's possible! Just need to change the Data Type property of the var to your <Entity> Identifier and adapt the code to that change. Can you do it or need some help?

Please see the example below:


BR,

Luis

 Yes, but the first value is 0 and I want to have a value from the first row of my Entity when I initially access to this screen

 


Sylvain

mvp_badge
MVP

Hi, did you try to pass that value as an input parameter? And assigned to the var in OnReady event action?

Sylvain Lapointe

Luís Cardoso wrote:

Hi, did you try to pass that value as an input parameter? And assigned to the var in OnReady event action?

 Hi Luis,

No... Can you explain this to me? :)

 

mvp_badge
MVP

Yes, sure!

1st step:

- Add Input parameter (same type of var) and OnReady event:


2nd step:

- On OnReady action assign the value of the input parameter to var:



mvp_badge
MVP

Hi,

Any news? The steps that I sent works?

mvp_badge
MVP

Hi Sylvain,

Also you can "OnInitialize" event for that,You can your variable here i also use same for that.

Also you can add condition if "InputPara" is nullidenetifire that set default value esle leave it as remain.


Regards

Rahul Sahu

Sylvain Lapointe

Rahul Sahu wrote:

Hi Sylvain,

Also you can "OnInitialize" event for that,You can your variable here i also use same for that.

Also you can add condition if "InputPara" is nullidenetifire that set default value esle leave it as remain.


Regards

Rahul Sahu

 Hi Rahul,


Make sense and it's work but the assignments IntergerToIdentifier(1), work only if you have an existing record with an Id of (1)? If the record Id (1) does not exist?

Thanks guys for your help!

Sylvain

 

mvp_badge
MVP

Sylvain Lapointe wrote:

Rahul Sahu wrote:

Hi Sylvain,

Also you can "OnInitialize" event for that,You can your variable here i also use same for that.

Also you can add condition if "InputPara" is nullidenetifire that set default value esle leave it as remain.


Regards

Rahul Sahu

 Hi Rahul,


Make sense and it's work but the assignments IntergerToIdentifier(1), work only if you have an existing record with an Id of (1)? If the record Id (1) does not exist?

Thanks guys for your help!

Sylvain

 

Hi Sylvain,

Yes you are right than do one thing.

1.Use max record 1 for aggreagte


2. use in filter condtion like below


3. Based on this condition it will check id CustomerID is null than it will return only one record default else return by ID record.

4. you can ascending descending order also.

Use this in your logic accrodinly.

Hope this will help you.


Regards

Rahul Sahu

mvp_badge
MVP

Hi Sylvain,

Did you try how I said in my last post? It's very similar to Rahul approach but with a different event (you can use OnInitialize ou OnReady, see the differences here).

Also, since the variables are of the same data type, you don't need to use the conversion "IntergerToIdentifier".

If the Id that you send doesn't exist in DB, the query will return empty and will not show any data on the screen.


BR,

Luis

Sylvain Lapointe

Luís Cardoso wrote:

Hi Sylvain,

Did you try how I said in my last post? It's very similar to Rahul approach but with a different event (you can use OnInitialize ou OnReady, see the differences here).

Also, since the variables are of the same data type, you don't need to use the conversion "IntergerToIdentifier".

If the Id that you send doesn't exist in DB, the query will return empty and will not show any data on the screen.


BR,

Luis

 Hi Luis,

Yes your right, it's almost the same method. But it's EXACLY my concern, How can I avoid a empty query? There must be a method to return the first Id from a entity query?


BR,

Sylvain

 

mvp_badge
MVP

Hi. You Can do the query and check if Is empty and implement some Logic when the query return no value. Why this Is a concern to you? I dont see any problem on that 

Hi Sylvain,

I get the feeling that maybe your question is not entirely clear to everybody.  You are using the master detail widget, right ?

So on the left pane you get a list and on the right you show details of whatever item in the list from the left is selected.  Did you follow this explanation to build it ?  So when you first open the screen, the list shows up on the left, but nothing on the right, until user first makes a choice on the left, right ?

So if this is you set up, the only thing you want changed, is that one of the items on the left is "pre-selected" as it were, already showing those details on the right without the user having to do anything ?  

Let's say you want whatever item is retrieved as first item in the list to be pre-selected.  You will have to add some logic once the list returns.  That would be by adding an onAfterFetch event to the aggregate that retrieves the list.  

In this OnAfterFetch, just do whatever you do, when an item in the list is clicked to populate the detail.  If you followed that explanation, that would be an assign statement to set the local Id variable to the selected item (by default that is the first), followed by a refresh of the aggregate that retrieves the details based on that id.


See attached oml, since I want exactly the same to happen in the onAfterFetch as when user clicks an item, I just reused the ClickSelectedUser as the OnAfterFetch.


Good luck,

Dorine

DemoMasterDetail.oml

mvp_badge
MVP

Dorine Boudry wrote:

Hi Sylvain,

I get the feeling that maybe your question is not entirely clear to everybody.  You are using the master detail widget, right ?

So on the left pane you get a list and on the right you show details of whatever item in the list from the left is selected.  Did you follow this explanation to build it ?  So when you first open the screen, the list shows up on the left, but nothing on the right, until user first makes a choice on the left, right ?

So if this is you set up, the only thing you want changed, is that one of the items on the left is "pre-selected" as it were, already showing those details on the right without the user having to do anything ?  

Let's say you want whatever item is retrieved as first item in the list to be pre-selected.  You will have to add some logic once the list returns.  That would be by adding an onAfterFetch event to the aggregate that retrieves the list.  

In this OnAfterFetch, just do whatever you do, when an item in the list is clicked to populate the detail.  If you followed that explanation, that would be an assign statement to set the local Id variable to the selected item (by default that is the first), followed by a refresh of the aggregate that retrieves the details based on that id.


See attached oml, since I want exactly the same to happen in the onAfterFetch as when user clicks an item, I just reused the ClickSelectedUser as the OnAfterFetch.


Good luck,

Dorine

Hi Sylvain,

@Dorine IS right, i forget about that. you are using "Mater-Detail" UI widget.

hope @Dorine solution will help you. :-)



Regards

Rahul Sahu

Sylvain Lapointe

Dorine Boudry wrote:

Hi Sylvain,

I get the feeling that maybe your question is not entirely clear to everybody.  You are using the master detail widget, right ?

So on the left pane you get a list and on the right you show details of whatever item in the list from the left is selected.  Did you follow this explanation to build it ?  So when you first open the screen, the list shows up on the left, but nothing on the right, until user first makes a choice on the left, right ?

So if this is you set up, the only thing you want changed, is that one of the items on the left is "pre-selected" as it were, already showing those details on the right without the user having to do anything ?  

Let's say you want whatever item is retrieved as first item in the list to be pre-selected.  You will have to add some logic once the list returns.  That would be by adding an onAfterFetch event to the aggregate that retrieves the list.  

In this OnAfterFetch, just do whatever you do, when an item in the list is clicked to populate the detail.  If you followed that explanation, that would be an assign statement to set the local Id variable to the selected item (by default that is the first), followed by a refresh of the aggregate that retrieves the details based on that id.


See attached oml, since I want exactly the same to happen in the onAfterFetch as when user clicks an item, I just reused the ClickSelectedUser as the OnAfterFetch.


Good luck,

Dorine

Hi @Dorine

It's exactly my need.  Sorry for my poor explanation, english is not my primary language ;)


Thank you all for your help, this community rocks ! 

Best regards,

SL 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.