Show stored value in autocomoplete

I have a autocomplete in the outsystems 8 to search for countries so t I have a User_Edit screen to edit a user, one of the fields is "Country" and Im using autocomplete for it.

 Its working, the autocomplete works and the value selected is stored in DB. 

However, when I access the User_Edit screen for a specific user the autocomplete country field doesnt appear populated with the country stored in the database, it just appears "Type or double-click to list".

 Do you know why? Probably the issue is that the autocomplete input field is associated with a local variable "CountrySearch" that is used in the filter but Im not understanding how to solve this properly.

Hi,

Is this the same issue that you reported here?

No, the value stored in dB for the country doesn't appear in the user edit screen of a specific user. 

Hello OsCaR,

it sounds like you are right, the input field gets populated from the local variable, which is empty when you load the screen, instead of from the database directly. You need to assign the value from the database to the local variable in your screen's preparation with an "assign", so that the field can be populated when the screen is rendered. That should solve the issue.

Best reagrds,
Michael

It seems that the issue is because the autocomplete field country, so the country, is not being stored in the users table. In the debugger, in the CraeteOrUpdateUser it appears: 

UserEdit.Record.User

 Name John

 ...

 CountryCod ""

... 

So the CountryCod is empty. The Country entity has the COD attribute of type text as the identifier. 

To solve this issue in the Save action of the UserEdit screen in an assign I add: UserEdit.Record.User.CountryCod = Input_AutoComplete_GetIdentifier(CountriesSearch.Id,PreviousIdentifier:) But like this it appears 'Country Identifier data type required instead of text'.


 Do you know why?

Because the Input_AutoComplete returns a Text data type, not an Identifier. You can use TextToEntityRefText (don't quite remember the correct name in version 8). It's a built-in function that allows converting a text to an identifier this way the warning should disappear.

But note that this is just to fix the warning, you still need to validate if the identifier is really there and being properly assigned to the attribute.

Thanks, now it seems that the country code is stored in the users table in the column "CountryCOD". 

However I have a table records that shows some details of the users like name, phone, etc and also the Country. 

To show the Country I have "UsersTable.List.Current.Country.Name" but like this in the table the country name dont appears. 

With "UsersTable.List.Current.User.CountryCod" it appears in the table records the correct country code, but I would like to show the country name, do you know why dont works like above with "UsersTable.List.Current.Country.Name"?

 In the preparation I have the User and Country entities then the conditions:

 User.Id = UserId 

User.CountryCod = Country.COD


And also in the user edit screen the country field is not populated with "UserEdit.Record. Country.Name"  in the variable. 

You need to have the Country in your query joined with the User.

Maybe you need to take a look into the online courses, check this one first.

Nuno Rolo wrote:

You need to have the Country in your query joined with the User.

Maybe you need to take a look into the online courses, check this one first.


Thanks but I already have that as I have in the previous reply. 

Without seeing any images or the code itself it's hard to point you to the correct issue.

 Did you check that the code exists in the country entity and that it has a name filled?

Nuno Rolo wrote:

Without seeing any images or the code itself it's hard to point you to the correct issue.

 Did you check that the code exists in the country entity and that it has a name filled?


Thanks, yes the country has the columns cod, that is the identifier, and the column name. 

The issue should be in the Preparation, in the preparation I have a GetUsersById query with: 

Parameters 

UserId 

Entities/Structures

 User

 Country 

Conditions 

User.Id =UserId 

User.CountryCod = Country.COD 

Adding a breakpoint to the preparation, when I acess the UserEdit screen for a specific user, in the debugger appaers the List > Current > User with the correct info, including the "CountryCod", for example "PL". 

However in the List > Current > Country all columns are empty:

 COD "" ...

 COD_NUM 0 

NAME "" ....

And what's the source record for the EditRecord, is it directly the query or it's a local variable?

Nuno Rolo wrote:

And what's the source record for the EditRecord, is it directly the query or it's a local variable?


It's the query. 

And the variables inside are from the EditRecord or from the query?

When you test the query does it show you the correct result ?

Nuno Rolo wrote:

And the variables inside are from the EditRecord or from the query?

When you test the query does it show you the correct result ?


Thanks, which variables? The query works but the country columns appear all empty or as 0.

The ones that you are using in the screen (input or expression).

I'm not referring in runtime or debug, but clicking on the Test button in the query.

The variables in the screen are like this:

 Name Variable: UserEdit.Record.User.Name

 phone variable: UserEdit.Record.User.Phone 

... other input variables 

country variable: CountrySearch 

In the preparation I have an assign after the GetUserById query: CountrySearch = GetUserById.List.Current.Country.Name

Nuno Rolo wrote:

The ones that you are using in the screen (input or expression).

I'm not referring in runtime or debug, but clicking on the Test button in the query.


Thanks, yes I tested the query and it works but the country columns are empty or 0.