1. date type of queries need to be converted,method as follows:
//Conversion time
string startdate = SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Now);
2. Obtain the value of the user types:
public List<WorkManEntity> GetUsersFromSPFieldUser(SPListItem item,string key) { List<WorkManEntity> fUsers = new List<WorkManEntity>(); SPFieldUser uField = item.Fields[key] as SPFieldUser; //This place can not judge the election, if the radio can get rid of
if (uField.AllowMultipleValues) // Allow multiple selections { SPFieldUserValueCollection userValues = item[key] as SPFieldUserValueCollection; foreach (SPFieldUserValue userValue in userValues) { if (null != userValue.User) { WorkManEntity user = new WorkManEntity(); user.LookUpID = userValue.LookupId; user.LookUpValue = userValue.LookupValue; user.loginName = userValue.User.LoginName; //add list fUsers.Add(user); } } } return fUsers; } 3. assigned to the user type
SPFieldUserValueCollection uvc = new SPFieldUserValueCollection(); SPUser pu = web.EnsureUser(user.loginName); uvc.Add(new SPFieldUserValue(web, pu.ID, pu.Name)); //user type
newListitem["Overtime member"] = uvc;