How to hold entire record value from combobox

I have a combo. For the combo box I set  all the required properties like:

Source Record,

Source Attribute,

Source Identifier,

Variable- this will store the source identifier for the selected value.

So my question is, is there a way so that we can catch both the identifier and attribute for the selected record into a variable.

My requirement is like, I want to show the selected attribute in some other label or expression, and I want to insert the selected id in to DB.

Given the Id, you can gett all attribute using entity actions: expand your entity there is action like GetYourEntity

Gede wrote:

Given the Id, you can gett all attribute using entity actions: expand your entity there is action like GetYourEntity

Thanks Gede. One question is like If I use the entity action, then is it going to hit the DB again, or else it will fetch all the attributes from local. And what if I'm using SQL query or stored proc to get the data?


For web development, it is always on server side.

Just use other entity action, like CreateYourEntity

It is helpful to think like this:

# web application: there is a client and aserver; a client always sends request to server to do an action

# mobile application: it is like network programming where there is 2 applications / processes that talk each other

Hi Bibhudutta Maharana,

You can get those values in expression by using the Get function of that entity. here i have attached a picture for your reference.


Thanks and Regards,

Wasim khan S


Bibhudutta Maharana wrote:

I have a combo. For the combo box I set  all the required properties like:

Source Record,

Source Attribute,

Source Identifier,

Variable- this will store the source identifier for the selected value.

So my question is, is there a way so that we can catch both the identifier and attribute for the selected record into a variable.

My requirement is like, I want to show the selected attribute in some other label or expression, and I want to insert the selected id in to DB.


Hi bibhudutta as much as I understand your question

I think you can do it with the help of get function it is very easy first add a action on your combo box onchange then save your id there and then ajax refresh your expression and inside that expression, Wright the function example (getemployee(id). employee.Name)

Bibhudutta Maharana wrote:

I have a combo. For the combo box I set  all the required properties like:

Source Record,

Source Attribute,

Source Identifier,

Variable- this will store the source identifier for the selected value.

So my question is, is there a way so that we can catch both the identifier and attribute for the selected record into a variable.

My requirement is like, I want to show the selected attribute in some other label or expression, and I want to insert the selected id in to DB.

Hi Bibhudutta,

If your source record is an aggregate\SQL query, then you can better filter the source record list available in the preparation using the Identifier of the selected attribute instead of fetching the attribute by calling Get entity action. 

Thanks,

Karthik 


Karthik Jeyaraman wrote:

Bibhudutta Maharana wrote:

I have a combo. For the combo box I set  all the required properties like:

Source Record,

Source Attribute,

Source Identifier,

Variable- this will store the source identifier for the selected value.

So my question is, is there a way so that we can catch both the identifier and attribute for the selected record into a variable.

My requirement is like, I want to show the selected attribute in some other label or expression, and I want to insert the selected id in to DB.

Hi Bibhudutta,

If your source record is an aggregate\SQL query, then you can better filter the source record list available in the preparation using the Identifier of the selected attribute instead of fetching the attribute by calling Get entity action. 

Thanks,

Karthik 


Yes, that's what I'm looking for. But can you please tell me how to do that. I just want to use that during an assignment.


IF this is what you want, you can use the ListFilter in the onchange event of your combobox.

# Say, u have a variable of type Movie and it has an attribute of MovieGenre.label

# just assigned the Movie.genrelabel = getmoviegenre(id).moviegenre.label

# then call createMovie

@Tuna: though that's certainly a possibility, that means an extra database access. If you can prevent that, like with a ListFilter as Stefano wrote, you're better off.

Stefano Valente wrote:

IF this is what you want, you can use the ListFilter in the onchange event of your combobox.

Hi Stefano. Your suggestion seems to be effective one. Can you please give a detailed step. The list is from aggregate and SQL.

Hi Bibhudutta,

ListFilter works by specifying the list (your Local Variable) and the condition. In your case the condition will be something like "YourEntity.Id = SelectedId" (where Id is the identifier of the Entity in your list, and SelectedId the selected Id from the Combo Boc).

Kilian Hekhuis wrote:

Hi Bibhudutta,

ListFilter works by specifying the list (your Local Variable) and the condition. In your case the condition will be something like "YourEntity.Id = SelectedId" (where Id is the identifier of the Entity in your list, and SelectedId the selected Id from the Combo Boc).

Actually the list is in the form of list of id and description pair. So what Stefano is saying is on the on change event, we can catch the selected description to some other variable. Can you please give me steps for this (actually I'm new to Outsystems, that's why).

On the onChange event we have to assign the selected description to some variable.


Solution

Hi Bibhudutta,

The ListFilter returns the Records of the List that adhere to the condition. If you filter on Id, it will be a single record (which you can access by the ListFilter.FilteredList.Current). In that record there's also the description you want.

Solution