Binding selected choice set value to default text of a drop down activity

Hello all,

I am having an issue binding the selected value of a choice set to be the default value of a drop down control.

I have an application which contains a table to display data, another page to search that data, and another page to edit that data. For the purposes of this question, lets say the data service entity I am using is named products and has two fields: productId and ProductCategory. Product category is a choice set that can be set to either “TypeOne”, “TypeTwo”, or “TypeThree”.

On the search page, users are able to search by product id. Once a product id is found, they can click an edit button that will open the edit page. In the event tab of the edit button, logic will take the value that is in the product id search field and assign it to a variable of “CurId” before launching the edit page. Once the edit page is open, a load event will query the data service and assign “SignleEntityContainer” (of type Products which is the name of my data entity) based on CurId matching the ProductId assigned on the previous page. The issue I am having is then trying to display the existing data for the productCategory field in a drop down containing the choice set options. I was able to bind the choice set options to the list source with “GetChoiceSet(“ProductCategories”)” and that works great. But when I try to get the existing product category assigned to this productId in the data service I run into issues.

In the default selected value field I have “GetChoiceSetValue(“ProductCategories”, SingleEntityContainer.ProductCategory.Value)” which I would expect to return the selected item. But instead, I get an error of "Value of type ‘String’ cannot be convert to ‘ChoiceSet’.

Any thoughts on how I can bind the default value of the data to this drop down? Thanks in advance!

@btclark

Welcome to the community

ideally you need to save the selected item on first page completely that is your product and then pass the product completely to the selected item instead of trying to get it again

GetChoiceSetValue(“ProductCategories”, SingleEntityContainer.ProductCategory.Value) - this would return a string but if you see the type of selected item it would need a product if you bind the products directly and then just pass the product from other page here

binding products directly and sending the sleected product as variable should work

Also one thing I observed is singleentitycontainer which is present in legacy apps..are you still using them? as legacy depreciation is announced

cheers

Hello Anil, thanks for your reply. Good tip on populating a variable of type product in the first page before moving to the second. I changed my logic to do so, however my issue of binding the selected item to the drop down still exists. In the list source property of my drop down, I am setting "GetChoiceSet(“ProductCategories”) which populates the drop down options with all options from the choice set. This also changes the expected type of the default selected value from a tabularInitClass to Choice set. Even still when I am setting the entire SingleEntityContainer variable in the first page, which is just an object of type products, I am running into issues when trying to call “GetChoiceSetValue(“ProductCategories”, SingleEntityContainer.ProductCategory.Value)” as that returns a string and it expects a choice set.