16
Views
7
Comments
Solved
Dropdown search - fill table fields with the dropdown result

Hello,

I have a question about how to proceed with a particular feature and needed some tips to know how I can do it in reactive application.

I have a list with a dropdown search field where I search for the employee, when I select an employee the rest of the fields: email and address must be automatically by the respective employeeid in that current row.

My question is what I have to do in the dropdown handler

Thanks

image.PNG

Rank: #515
Solution

Hi Anushka Fiji,

After think about your problem and studied Nuno Reis' nice solution, I realized that, maybe, your goal was present a list of requests and allow users to change the employees related to them. Well, if it is what you want, I have made an example with the sample data (list of employees in which it is possible to change their managers) - oml attached.

This was only possible because two different entities were used. But, if you just use one entity, as in your previous OML file example, I think you should consider changing the usability flow. Perhaps using a modal to change the register and then to refresh the aggregate.

Another think is, if you won't change the register in database on DropdownSearchOnSelect, your user could miss all data changed when clicking in the navigation bar or in the sort columns widget.

Well, hope it helps.

Best Regards.

AppTestRequest.oml

mvp_badge
MVP
Rank: #71
Solution

You don't have to use the block. It was just easier to explain by saving only the EmployeeId. You can create a structure and instead of only EmployeeId, save Id+Name+Phone. This way you can also use the Order By if you want.

The key error in your approach is that you need to have a separate list. One thing is the GetEmployee that has all the employees. Another thing is the MyEmployees where you save the ones you want to see.

If what you want is to edit employees, you can do it. But in that situation, I don't see why a dropdown would be useful. Editing a name is not the same as picking a name.

I did a new page. Follow the"Edit User" link and see if that is what you are trying to do.


PS: I see that you only joined OutSystems today. If this seems too hard, I can try to explain differently.

AppTest.oml

mvp_badge
MVP
Rank: #71

Hello Anushka.

You get the id selected in the dropdown and use it to fetch the user information.

The moment you assign the email/address to the variable on screen, it will refresh.


I attached an example.

ReactiveUserSearch.oml

Rank: #55551

Hi @Nuno Reis, thanks for the reply.

but I don't think I explained myself well.

I have a dropdown search for each record in only one field within the table, where I will search for an employee and fill in the remaining fields (email ...) of that particular employee id that I am selecting.

I attached an oml to give an idea of what I'm talking about

AppTest.oml

mvp_badge
MVP
Rank: #71

You have two issues here.

1. You can't have a single email variable for all the rows.

Simply fix your link to use GetEmployee.List.Current.Sample_Employee.Email (just like you link was doing) and it will work. But...


2. The GetEmployee is showing everyone. This way, you will always get everyone!

I changed it to have an empty list that you fill one by one (button Add Request creates an empty row).

Then I created a list for you to save EmployeeIds selected on the dropdown.

Finally,  I changed the email/phone information to a block that gets refreshed whenever you change the person.

I had to remove the Order By from columns or it would make the scenario a lot worse.

See if it is clear now.


List of changes:

AppTest.oml

Rank: #55551

Hi Nuno, thank you again.

Now I realized why I was not getting the result I needed. I realized that I couldn't have the same variable I just didn't understand that I would have to have the webblock and pass on what I have selected.

But, therefore, I cannot, for example, have the source of the table with all the GetEmployee to appear the whole list and then when I wanted to edit would I have the possibility to change the employee in the dropdown and consequently edit the entire record?Did much change in this case?

Thank you very much.

mvp_badge
MVP
Rank: #71
Solution

You don't have to use the block. It was just easier to explain by saving only the EmployeeId. You can create a structure and instead of only EmployeeId, save Id+Name+Phone. This way you can also use the Order By if you want.

The key error in your approach is that you need to have a separate list. One thing is the GetEmployee that has all the employees. Another thing is the MyEmployees where you save the ones you want to see.

If what you want is to edit employees, you can do it. But in that situation, I don't see why a dropdown would be useful. Editing a name is not the same as picking a name.

I did a new page. Follow the"Edit User" link and see if that is what you are trying to do.


PS: I see that you only joined OutSystems today. If this seems too hard, I can try to explain differently.

AppTest.oml

Rank: #515
Solution

Hi Anushka Fiji,

After think about your problem and studied Nuno Reis' nice solution, I realized that, maybe, your goal was present a list of requests and allow users to change the employees related to them. Well, if it is what you want, I have made an example with the sample data (list of employees in which it is possible to change their managers) - oml attached.

This was only possible because two different entities were used. But, if you just use one entity, as in your previous OML file example, I think you should consider changing the usability flow. Perhaps using a modal to change the register and then to refresh the aggregate.

Another think is, if you won't change the register in database on DropdownSearchOnSelect, your user could miss all data changed when clicking in the navigation bar or in the sort columns widget.

Well, hope it helps.

Best Regards.

AppTestRequest.oml

Rank: #55551

Hi @Nuno Reis and @Kadu Borges,

thanks for the time spent helping me.

I marked the two answers as a solution because I will combine the two for what I want to do. . I'm new to outsystems so it helped a lot.

Thank you very much for your help.