TokenList ValueChangeListener not working

I have a token list with options datasource from Users table and datasource as Users as well.
I am trying to add a ValueChangeListener so that I would validate the field cannot be filled with more than 2 users. But for some reason it seems like the ValueChangeListener is not called on the tokenList field.

Any suggestions for how I can fix this problem ?

  interviewersTokenList.addValueChangeListener(e-> {
  	if(e.getValue() != null) {
  		List<User> list = (List<User>) e.getValue();
  		if(list.size()>2) {
  			showNotification("Invalid number of users");

Thanks in advance,

Hello, @zuco_ivan

Unfortunately, this functionality is not implemented for TokenList. You can find the following message in log: addValueChangeListener not implemented for TokenList.

I suggest that you use the addCollectionChangeListener and removeCollectionChangeListener methods for a datasource that is bound with TokenList.


1 Like

Yup, that works. Thanks