27
Views
6
Comments
Solved
Problem with if-else in Container
Question

Hello everyone,

I have a theoretical question.

I have created a form for the onboarding of a new employee.


I have 2 databases. Database employee and softwarelist.

The database softwarelist contains a foreign key of employee.

In the database softwarelist all software names are already entered.

There are 8 departments in the company and they use different software, but some use the same software.


When the clerk for example selects the department (Human Resource) in the form, I want only the software used in that department to be displayed as a checkbox. This is quite simple with the help of an if-condition in the container. I can then drag the software into the TRUE area. 

The problem is, however, that some departments use the same software and once I have dragged one software into a container, I can no longer do it for the other department. 

Is there a tip or trick for this?

Thank you very much.


Solution

Now as you have used the hard coded value of Department (i don't think so that is part of best practice we should use value from entity), add all department name in single IF condition which has same software.

for e.g,

Department HR = Software ABC

Department IT= Software ABC

Department Finance =Software XYZ

your if condition will be for MS Office check box,

Aggregate.List.Current.Entity.DepartmentName="HR" or Aggregate.List.Current.Entity.DepartmentName="IT"  

You need to do same for all the check boxes where more than one department shares the same software. 

Regards,

Komal

Hello Sezer,

Is your software associates with the department Id?

For example 

Department Human Resource (Id=1)  has Software ABC (id=1)

and Department Finance (Id=2 ) also ha Software ABC (Id=1)

Now if you select the Human resource with Id =1 it should populate the Software ABC

and again if you select Finance with Id 2, it will populate the Software ABC.

In the database of department, you need to map Department id with specific software id, then its possible to have same software for multiple departments.

Hope this helps,

Komal 

Hello @Sezer Kabaoglu,

It looks like you are newbie to OutSystems and programming. If so, you are welcome to the OutSystems community and world of programming. In order to fulfill your requirements you can create a new third entity Department and have a one to many relationship in between Software and Department entities. 

However, I would suggest you to please go through with the training material and documentation to learn and explore the concepts. Here are some links for your reference.

https://success.outsystems.com/documentation/11/developing_an_application/use_data/data_modeling/

https://learn.outsystems.com/training/journeys/web-developer-662/-0

Thanks,

Sachin

Hello Komal,

first of all, thank you for your reply.

My software is not associates with the department Id.

I can show it so:

My form looks like this:
This data will entered into the database "employee"

The data is entered and, for example, the HR department is selected and at the bottom there is a save button which then automatically forwards to the next page.


New Screen: The Employeename will automatically selected because of InputId-Parameter

This data will entered into the database "softwarelist". 



I already know which departments use which software, so I want to solve it with if-conditions in the container area. 


I said for example, show me this 3 Software, if department "HR" is selected. But MS Office will use also for the deparment "IT". But I have already dragged MS-Office into the true-area of my if-condition in the container. I cant drag it into another container, because there is only One label of the checkbox "MS Office". Please ignore the error message, I just wanted to give you a quick illustration of what I mean. I haven't programmed the logic yet because I have an existing problem

My databases also look like this:

Best regards

Hello,

Are you using hard coded value of "MS Office" in your if condition?

Are they software's tick boxes are prepopulated based on selection of department in previous screen?

if yes then yes it won't be available for other department, for that mapping is required with one -to-many relationship between department and software.

Regards,

Komal

The check boxes will not prepopulated,  but based on the selection of deparment in previous screen the checkboxes should to be displayed like this example. So they provided for the selection. Without if-else, all software would be displayed. 
For example HR use the software ABCDEFG, only this software should be displayed instead of all of them.
For this challange i want to use the if-condtion in the Container how I said. 
The if condotion would be like:  

if department = "HR"
True= checkbox "MS Office"


best regards

 

Solution

Now as you have used the hard coded value of Department (i don't think so that is part of best practice we should use value from entity), add all department name in single IF condition which has same software.

for e.g,

Department HR = Software ABC

Department IT= Software ABC

Department Finance =Software XYZ

your if condition will be for MS Office check box,

Aggregate.List.Current.Entity.DepartmentName="HR" or Aggregate.List.Current.Entity.DepartmentName="IT"  

You need to do same for all the check boxes where more than one department shares the same software. 

Regards,

Komal

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