A Customer had created a custom InfoPath form to add a new item in the list. It gets added, but when he is trying to filter it using the field value =[Me], the filter does not work and all the items are shown to everyone.
Basically they are pulling in the items from User Information list from SharePoint and adding them to a drop down in InfoPath form, from where the user selects the user and the final item is added to their custom list.
But why filtering is not happening? When checking their list, found that they have used “Single line of text” as their field type to store the username !!
SharePoint does not know how to compare or validate a user inside a “Single line of text” field, so it just ignores the formula given in the View and displays all the records.
Now a very visible thing looks like we need to change the field type from “Single line of text” to “Person or Group” type which will allow filtering of data on [Me] filter. But on other hand, InfoPath does not know how to handle the “Person or Group” type field, so it is still sending out the plain text.
Then it was ascertained that we need an event handler which will sit in-between and capture each item being added. That event handler will pull in the username from the item being submitted and convert it to the SPUser format that “Person or Group” field understand.
So the code was written to get the data from InfoPath form and create a “Person or Group” field value from there on.
Happy Coding and have fun…