Home > Forum > Forms > Choice field limit to list

Choice field limit to list
0

I have a choice field and it is populated from a data source with autocomplete activated. I want to limit the choice field to only the data from the data source. The user can't manually type any other text. How can I accomplish this?. Thanks

MVP

HI,

In the configuration of the attribute, it is possible to select whether it is possible to add a value from outside the data source.

But if after entering text that is not a value for the data source, if you follow a path that has data validation unchecked, it will be possible to save the form with such data.
For such cases, on paths that are not validated, you can add validation actions and check if the value from the attribute (Name) is in the data source (name column).

The same applies to the save button on the bar, you can also connect this validation action there.

Regards

MVP
In reply to: luis

Can the error message be customized? I would like to say that the chosen vendor is not in the list

This standard message does not, because you may have several fields that have wrong data.
However, you can add validations on the path: as in the screenshots I added.
Or more simply, check if your attribute contains data in the format ID#Name: atr like '%#%' , added in the validation rule on the path.

Regards

MVP
In reply to: luis

Can the error message be customized? I would like to say that the chosen vendor is not in the list

Hi luis,
I don't have information about changing that message, but maybe this will be a way.

1. Turn off the 'required' mark for the field - it's needed to make next step work.
2. Create validate form action on path with custom error information. Make the action check two things:
- if value of the field is not empty (so we don't loose the required part)
- if value is in data source (example rule attached - parameter is not needed, it can be just a field from form)

Without turning off 'required' you would get same error as now.

I've been also thinking about second way with on change form rule, but it seems that 'Autocomplete dropdown' activates on change event only when there is value selected that exists in source so it's not possible to show a prompt when somebody types value thats not in source. Unless you allow for values from outside the source and change it with 'pen' icon on the field.

MVP
In reply to: luis

The choice field is case sensitive. How do I change it to non-case sensitive?

It depends on the data source and the settings of the database they come from. If you have the opportunity and it will not affect other uses of this database, you can change the Collation setting for the database or table (It is important to make a backup of the database before making changes). Another solution is to create a view and set the collate accordingly. e.g.


CREATE VIEW name_view AS
SELECT col1 COLLATE SQL_Latin1_General_CP1_CI_AS AS col1_non_sensitive,
col2 COLLATE SQL_Latin1_General_CP1_CI_AS AS col2_non_sensitive
FROM your_tab;

here is example how to check collate in sql studio

SELECT 'Test' as dd WHERE 'Test' COLLATE SQL_Latin1_General_CP1_CI_AS = 'TEST' COLLATE SQL_Latin1_General_CP1_CI_AS;
SELECT 'Test' as dd WHERE 'Test' COLLATE SQL_Latin1_General_CP1_CS_AS = 'TEST' COLLATE SQL_Latin1_General_CP1_CS_AS;