Monday, 23 February 2015

Exception “The user does not exist or is not unique…”

Hi All,

Today new issue and solution J

Issue: We were adding the item into list using Java Script Object Model (JSOM). We have one field in list is of type UserMulti as

<Field ID="{}"
         Name="Users"
         DisplayName="Users"
         Type="UserMulti"
         UserSelectionMode="PeopleOnly"
         Required="TRUE"
         Group="My Site Columns">
  </Field>

We need to submit the multiple users to the list.

Following is the code snippet (sample code snippet J) we have to add the item in the list 

When we are adding single or two users in above user field it was working very fine.

But when we are trying to add three users then we are getting an exception: “The user does not exist or is not unique…” with following stack trace.

Fig 1. Exception while adding item in a list with MultiUser field from JSOM
Solution:

This seems to be strange issue since adding two users are working but not more than two users.

After digging more, it found that there is one property “Mult” which need to be specify. 

According to MSDN
Mult
Optional BooleanTRUE to allow a lookup field to contain multiple values. The default is FALSE.
So after setting this property fields schema looks as

<Field ID="{}"
         Name="Users"
         DisplayName="Users"
         Type="UserMulti"
         UserSelectionMode="PeopleOnly"
         Required="TRUE"
         Group="My Site Columns"
  Mult="TRUE">
  </Field>

After changing the field schema it started working like a charmJ


Thanks!


Feel free in case of any comments / feedback / suggestions