Sunday, 17 May 2015

Get User Information List By means of Base Template Code



Sometimes it may happened that you are dealing with a multilingual site  collection and the with the change in language, the name of the User Information List also changes. And the program generates
"No List Found" error. To overcome the problem, we can use the Base Template code of the list to find necessary information. The method is illustrated below for developer's sincere observations:



private List GetUserInformationList(ClientContext clientContext)
        {
            try
            {
                var lists = clientContext.Web.Lists;
                clientContext.Load(clientContext.Web.Lists);
                clientContext.ExecuteQuery();

                foreach (var list in lists)
                {
                    /* BaseTemplate code of the User Information List */
                    if (list.BaseTemplate == 112)
                    {
                        return list;
                    }
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
            return null;
        }



Happy SharePointing...!!

No comments:

Post a Comment