In below example, I’ll demonstrate how to display users to people picker web control and get data from the same control. I have field called “Staff Assigned” and its data type is People/Group.
Below code will tell us how we can take data from that people/Group field and display to people picker SharePoint web control and also get data from people picker and give back to people/Group field from object model programmatically.
//Display users from people/Group field to People Picker Control
if (itmAudit["Staff Assigned"] != null)
{
char[] to_splitter = { ';' };
string to_list = itmAudit["Staff Assigned"].ToString(); // Reads value stored in SPList. (i.e., "Domain\User1; Domain\User2")
string[] arr = to_list.Split(to_splitter);
string user = string.Empty;
System.Collections.ArrayList entityArrayList = new System.Collections.ArrayList();
for (int i = 1; i < arr.Length; i++)
{
if ((i % 2) != 0)
{
user = arr[i].Substring(arr[i].IndexOf("#") + 1);
PickerEntity entity = new PickerEntity();
entity.Key = user;
entity = userPicker.ValidateEntity(entity);
entityArrayList.Add(entity);
}
}
userPicker.UpdateEntities(entityArrayList);
//Save users to people/Group field from People Picker Control
SPFieldUserValueCollection values = new SPFieldUserValueCollection();
foreach (PickerEntity entity in userPicker.ResolvedEntities)
{
SPFieldUserValue fuv = new SPFieldUserValue(SPContext.Current.Web, Convert.ToInt16(entity.EntityData[PeopleEditorEntityDataKeys.UserId]), entity.Description);
values.Add(fuv);
}
itmAudit["Staff Assigned"] = values;
Wednesday, June 17, 2009
How to display users to SharePoint People Picker control and get data from SharePoint People Picker control
Labels:
Display data to Sharepoint People Picker,
Display users from people/Group field to People Picker Control,
display users to Sharepoint People Picker,
get data from Sharepoint PeoplePicker,
get data from Sharepoint PeplePicker,
How to display users to People Picker and to get data from Peple Picker,
how to display users to people picker web control,
How to display users to SharePoint People Picker control and get data from SharePoint People Picker control,
How to use sharepoint PeoplePicker?,
People/Group Sharepoint Field,
Person/Group Field Type,
PickerEntity,
Sharepoint,
Sharepoint Field Types,
Sharepoint List Field Types,
SharePoint web control
Subscribe to:
Post Comments (Atom)
Hey,
ReplyDeleteNice article Disha, actually I was looking for how to take values from SharePoint People Picker control and update those values into SharePoint list columns, and I have found your article, your information is very good and precise also.
Thanks a lot for the nice information.
-Sanket
Hi Disha,
DeleteMy requirement is to populate a Peoplepicker control on change of a dropdown. I have different Departments, displaying in a dropdown. OnSelectedChangedIndex I want to show the contact person name in the people picker control.
It's settign for the very first time but after that it is showing the old values. Not refreshing the DisplayText name.
I am new to MOSS 2007, need ur help.
Thanks in advance.
Thanks For the Comment
ReplyDelete[...] http://dishashah.wordpress.com/2009/06/18/how-to-display-users-to-sharepoint-peoplepicker-and-to-get... Enjoy!! [...]
ReplyDeleteHi Disha,
ReplyDeleteI googled and browsed to many pointers. Yours is the most helpful one! The only question I have is: is there any way to check if PickerEntity is a user(people) or a group? I want to save users and groups data in different places.
Many thanks,
-HB
Hey HB
ReplyDeleteI am glad because it helps you. Thanks for Comment and appreciation.
Answer of your Question is :
You can read the resolved users and groups that the user has entered by using the editor's ResolvedEntities property, which is an ArrayList containing a list of PickerEntry objects. Each PickerEntry object contains an EntityData property bag which includes a "PrincipalType" field. You can use this to determine whether the resolved entity is a user or group.
foreach (PickerEntity entity in pplEditor.ResolvedEntities)
{
switch ((string)entity.EntityData["PrincipalType"]) {
case "User":
// ... do stuff here ...
break;
case "SharePointGroup":
// ... do stuff here ...
break;
}
}
Enjoy :)
Disha Shah
Hi Disha,
ReplyDeleteThank you so much for your help. It works like a charm!
I got another question about the group users: is it possible to retrieve all users for a given group? Like getting user names for a SharePoint group.
switch ((string)entity.EntityData["PrincipalType"]) {
case “SharePointGroup”:
//SPUserCollection users = GetUsersByEntity(entity);
//List users = GetGroupUsers(groupName)
break;
}
Thanks again!
HB
Yes HB, everything is possible in this world :) just we need to see which solution fits for our requirements.
ReplyDeleteYou can try below code to get list of users from SharePoint group.
case "SharePointGroup":
if (entity.EntityData.ContainsKey("SPGroupID"))
{
int groupID = int.Parse((string)entity.EntityData["SPGroupID"]);
SPGroup group = web.Groups.GetByID(groupID);
foreach (SPUser user in group.Users)
{ //Do Stuff }
}
break;
Thanks
Disha Shah
Hi Disha,
ReplyDeleteThank you for you answer! I got it work with your help. One thing I need to change is using web.SiteGroups instead of web.Groups, which throw a "Group cannot be found" exception at run time.
Wish you have a nice weekend!
HB
HB,
ReplyDeleteIt's good to hear that it helped you..
You too also have a great weekend ahead !!
-Disha Shah
Hi Disha,
ReplyDeleteYour article is really very useful to me. Appreciated.
One more thing i would like to know that How to make 'read only' people picker in custom list. I tried a lot but i could not find a solution even I have tried using objField.ReadOnlyField = true; but it hides this entire field.
Regards,
Viraj Vashi
Viraj,
ReplyDeleteThank you very much for the appreciation.
Can you please let me know what do you mean by "making read only people picker into list" ? Are you trying to do that end user won't able to enter/select any value/users into people picker control?
"objField.ReadOnlyField = true" comes with SPField object, if you want to make people picker in read only mode then you can write "peoplepickerctl.Enabled = false", so end user can't type anything into people picker control.
Please let me know if you are looking for something else.
Thanks, Disha Shah
Hi Disha,
ReplyDeleteThank you very much. I was looking exactly you have sent to me.
Regards,
Viraj Vashi
Hi Disha,
ReplyDeleteThank you very much for spent your important time for me.
I have one more query which is:
I have one custom list whose name is 'Defects' and in that custom list i have one lookup control whose name is 'Project Name'(Which comes from Project details list) and one more column i have which is 'Assigned To'(which is people picker). I want to display display users in 'Assigned To' column based on Project name column.
For better understanding...
Project name: Lookup control(Dropdown list)
Assigned To: People picker
I hope you will understand my problem.
I would be appreciated your help.
Regards,
Viraj Vashi
Viraj,
ReplyDeleteAs per your requirements, you are saying that depends on Project name you need to display assigned to value, it implicitly says that you must have column either in Project List as "Assigned to" or you have a new custom list which has "Project Name" and "Assigned To" column. I mean you need some type of mapping between those two columns.
Now how you fill "Assigned to" depends on "Project Name" column, right?
Well you can use a custom web part and write an event handler based on "Projectname_selectedindexchanged" and use SPquery to find the "Assigned To" field and assign value into your web part.
Second option, if you don’t want to write web part then you can use event handler as "Item Added" and fill the value of "Assigned To" and display the value.
Hope this helps!
Thanks,
Disha
Thank you very much for quick reply.
ReplyDeleteYou understood perfectly my question.
I agree with you first option and i tried also but i can not go with first option.
In second option,as you said that i need to write in "Item Added" event but it only fires when we click on OK button right?
Both columns are in same custom list and I want respective value of people picker control based on dropdown list of lookup control(project name). (Same like selected index changed event in ASP.net)
I am explaining you in details:
Suppose in project name there are: ERP System,Hospital Mgt etc(which binds from 'project' custom list) data. If user will select ERP system then in people picker their project owner's value will come means ERP System's project owners will display. Eg. Viraj Vashi;Abc; are project owner of ERP sytem.
Hope you have clearly understood.
Thanks in advance.
Regards,
Viraj Vashi
Viraj
ReplyDeleteIt is like when a person selects "Country" from user interface we need to display "States" related to that "Country" .(Filter from Country)
Now if you cannot go with the first option, then I can suggest about use "Custom Field Controls". It will fulfill your requirement, because I couldn't find a way to do this out of the box.
But you need to decide which way you want to go ahead
If I am at your place then If I need to do this kind of thing Project name-->Assigned to only once ,then I will go with webparts and If I have to use multiple times ,then I will go with custom field controls.
This is very useful link how to create and deploy custom field controls
http://datacogs.com/datablogs/archive/2007/08/26/641.aspx.
Hope this helps..
Disha Shah
The code works well for displaying and saving however when i use the save method:
ReplyDelete//Save users to people/Group field from People Picker Control
SPFieldUserValueCollection values = new SPFieldUserValueCollection();
foreach (PickerEntity entity in userPicker.ResolvedEntities)
{
SPFieldUserValue fuv = new SPFieldUserValue(SPContext.Current.Web, Convert.ToInt16(entity.EntityData[PeopleEditorEntityDataKeys.UserId]), entity.Description);
values.Add(fuv);
}
itmAudit["Staff Assigned"] = values;
I get ERROR
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
any advice would be greatly appreciated!
Sorry, to claify i am using the save mehtod on spitem update and am getting the error. No errors on spitem add.
ReplyDeleteHey Nick
ReplyDeleteCan you try one thing first for me?
Update that list item by SharePoint list user interface not from object model code.
Go to that list and edit any item and save it. Check whether that error comes or not?
Even this error also new to me...I just goggle it and I found related links...Can you please go through that?
http://sharepointbergen.blogspot.com/2007/04/customizing-andor-extending-or.html
http://blogs.msdn.com/circularfile/archive/2008/06/11/unexpected-sharepoint-list-definition-behavior.aspx
http://www.codeproject.com/Messages/3187992/Re-Catastrophic-failure-Exception-from-HRESULT-0x8.aspx
According to all links, there are some possibilities like error in Schema.xml if you create that list as feature.
Hope this helps!!!!!
Best Regards
Disha Shah
Hi Disha,
ReplyDeleteI appreciated your quick reply.
I have gone through your all helpful links but unfortunately i could not find the solution which i was looking for. If possible then kindly send me the steps and code for atleast state and city custom field control.
I would be very thankful to you.
Regards,
Viraj Vashi.
Hi Disha,
ReplyDeleteI tried it but i am also getting same error.
Regards,
Viraj Vashi
Hey Viraj
ReplyDeleteI am planning to write article related to custom field type, it is under construction and will take some time to finish it.
Mean while, Please go through below links, which will helpful for you to start your development work for custom field type.
http://vspug.com/nicksevens/2007/08/31/create-custom-field-types-for-sharepoint/
http://msdn.microsoft.com/en-us/library/bb684919.aspx
Thanks,
Disha Shah
Hey Viraj
ReplyDeleteCan you try one thing first for me?
Update that list item by SharePoint list user interface not from object model code.
Go to that list and edit any item and save it. Check whether that error comes or not? Can you please let me know outcome whether error comes or not?
Can you tell me you deployed that list on that site collection with feature or you created as a custom list from SharePoint user interface?
Please provide me with these two information...So I can get some direction.
Thanks
Disha Shah
Hi Disha,
ReplyDeleteI am sorry to say that but i did not get you.Can you please explain me in details? Actually I don't know What is SharePoint list user interface?
Regards,
Viraj Vashi
Viraj,
ReplyDeleteSharePoint list user interface means, open your SharePoint site into browser, go to your custom list, click on "New" button and try to enter some data into user interface and clicks on “save” button to see whether you are getting error or not?
If you are not clear, then please start new thread for comments with detail description, actually I am also confused that for which thread you wrote “I tried it but i am also getting same error”
Thanks,
Disha
Viraj,
ReplyDeleteI have written article on how to create custom field type, please go through this link, it will describes you each steps.
http://dishashah.wordpress.com/2009/11/05/step-by-step-tutorial-for-how-to-create-and-implement-custom-field-type-in-sharepoint/
~Disha Shah
Hi Disha,
ReplyDeleteThank you for explained me Sharepoint list user interface.
I have tried the same but i have not got any errors.
It saved without any error.
Regards,
Viraj Vashi
Hi Disha,
ReplyDeleteI have one query related with people picker.
I want to allow to search only those users who are assigned for respective project in people picker.
I am explaining you my requirement in details:
I have tow custom lists.
One is CustomList_Project:
In CustomList_Project custom list, i have following columns:
1) Project name: Textbox(User enter project name)
2) Assigned To: People picker(User assigned for this project)
Second is: CustomList_Second
1) Project name(which is lookup control and whose values come from CustomList_Project(which is custom list)
2) GetProjectOwner : People picker: When i select project name then it would only allow to search those users who have assigned for this project.
(By default it is comming all users)
I know that this is quite difficult query but i am sure that as per your knowledge and experience in sharepoint it would not be difficult to solve this.
Regards,
Viraj Vashi
Viraj
ReplyDeleteHere are some ideas which comes into my mind, from where you can achieve your functionality.
#1 ) You can write event handler on “CustomList_Project” list and when you add/insert new project name and assigned to fields, create new SharePoint Group named with “project name” and add/insert assigned to user into SharePoint group as Users.
Now when you are looking for project name into “CustomList_Second” list, on post back of current page, search/find for “project name” into all SharePoint group and assign that SharePoint group name into People Picker Property of “GetProjectOwner’ field, in these way – you can see only users which has been added to SharePoint group name (as per you - search those users who have assigned for this project), instead of all users.
#2) Change your interface slightly - Instead of GetProjectOwner as People picker control, put drop down box for GetProjectOwner field, and write code in which when user select Project name into “CustomList_Second” list then search for same project into “CustomList_Project “ list and take “Assigned To” value and populate into GetProjectOwner drop down box.
Hope you will get some answer from these points.
Thanks,
Disha
Hi Disha,
ReplyDeleteThanks a lot for your reply.
Disha, Actually I want exactly the same which you have written in #2)point in reply. I also want to achieve this thing but it is separate requirement. Do you have any idea how to populate dropdown list based on CAML query condition. Eg.
SPList lstCommunity = web.Lists["Community"];
SPQuery qry = new SPQuery();
qry.Query = "" + CommunityId + "";
DataTable dtCommunity = lstCommunity.GetItems(qry).GetDataTable();
Now I want to display datatable value in dropdownlist so tell me how to achieve this or you can give other example of CAML query with dropdownlist or lisbox control.
Now i am comming with my people picker requirement, which is either i could not explain you properly or you could not understand properly.
Disha, Actually i want to allow only those users who have assigned for that project and i must have to use people picker for that. Eg. User will type "Viraj Vashi" in people picker and Viraj Vashi user is available but it should not allow to search only when it is assigned for that project means when user type "Viraj Vashi" in people editor that time it should show message like "invalid user or this user is not allowed for this project". Hope now you have understood properly.
Regards,
Viraj Vashi
Viraj
ReplyDeleteExample of SPQuery:
SPList objList = SPContext.Current.List.Lists[“ListName”];
SPQuery strquery = new SPQuery();
string Query = string.Empty;
Query = "OrderBy" +
"FieldRef Name='FileLeafRef'" +
"OrderBy" +
"Where" +
"Eq" +
"FieldRef Name='DocIcon' " +
"Value Type='Text' xml Value" +
"Eq" +
"Where";
strquery.Query = Query;
SPListItemCollection objListItemColl = objList.GetItems(strquery);
cmbList.DataSource = objListItemColl;
cmbList.DataTextField = strDataTextField;
cmbList.DataValueField = strDataValueField;
cmbList.DataBind();
NOTE: somehow, special characters are not being display into query, write query as per your requirements.
On first look only, I understand your People picker requirements, and given the options/ideas what I was thinking about regarding alternate solutions.
Thanks,
Disha Shah
Hey Disha,
ReplyDeleteThank you very much. I was exactly looking the same. Amazing!
If possible then please try to find out about people picker requirement.
I understand that it is difficult to achieve but i am sure that you would find any alternate solution.
Regards,
Viraj Vashi
Hi Disha
ReplyDeleteIm new to share point .Just have 1 year exp in ASP.net(C#).Can u please give me the links of the resourses where i can start learning sharepoint,which can give complete understading of sharepoint.
It will be really helpful
Narpal
ReplyDeleteIt is good to hear that you want to start Sharepoint.
You can download "Software Development Kit" for Windows Sharepoint Service and Microsoft Offfice Server 2007 from microsoft, which gives you detail explanation for every componene of Sharepoint
Here are the links!!!!
http://www.microsoft.com/downloads/details.aspx?FamilyId=6D94E307-67D9-41AC-B2D6-0074D6286FA9&displaylang=en
http://www.microsoft.com/downloads/details.aspx?familyid=05e0dd12-8394-402b-8936-a07fe8afaffd&displaylang=en
Hope you can start on this!!!!
Thanks
Disha Shah
I'm Creating Task[list] in object model whenever request[List] is created. I'm sending mail to Admin Group related to request raised[raised request is task to admin,lets assume]. I'm able to send mails to Admin group but I want to send the link in mail so that on clicking that link he will login and will go to that particular task and will do the stuff there.
ReplyDeletehow can i do that .I hope i have express the problem rightly.
Hi Disha
ReplyDeleteI’m Creating Task[list] in object model whenever request[List] is created. I’m sending mail to Admin Group related to request raised[raised request is task to admin,lets assume]. I’m able to send mails to Admin group but I want to send the link in mail so that on clicking that link he will login and will go to that particular task and will do the stuff there.
how can i do that .I hope i have express the problem rightly.
Hi Disha
ReplyDeletei am new to sharepoint.having 1 yr experience in asp.net(c#).
can u suggest some tips regarding sharpoint custom controls .
Narpal
ReplyDeleteAccording to my understanding, you want to send link for created a new task into email.
If yes then you can write this in your code to achieve that:
SPContext.Current.Web.Url + "/Lists/" + SPContext.Current.Web.Lists["Tasks"].Title + "/DispForm.aspx?ID=" + itmTask.ID.ToString();
Thanks,
Disha Shah
Babu
ReplyDeleteGood to hear that you want to start with SharePoint. But I am little bit confused - what do you mean by SharePoint Custom Control?
Do you mean by Custom web parts or something else?
Please elaborate on what exactly you are looking for.
Thanks
Disha Shah
Hi Disha
ReplyDeleteThanks for Ur solution.Really You are helping alot to New people in share point.I have a query and i will be delighted if i get quick reply.I have to display dash board (Bar chart) using external datasource.can u please explain or give some respective link .
Hi Disha,
ReplyDeleteThank you for you Quick Reply,Your R Correct I Am Asking About Share point Custom Web parts.
Babu
Babu
ReplyDeleteThe best Example step by step for creating webpart is
http://msdn.microsoft.com/en-us/library/ms452873.aspx
http://www.wrox.com/WileyCDA/Section/Developing-SharePoint-2007-Web-Parts.id-306330.html
Start on this, and then you can have better idea about webpart.
Hope this helps
Thanks
Disha Shah
Narpal,
ReplyDeleteIt seems that Santosh, you and Babu are doing some type of competition; sometime you all have same type of requirements :)
You can also refer same links which I sent to Santosh and you can also do one thing over here, if you want to use external data source into Dashboard, then use BDC functionality and take external data source into SharePoint List and then use SharePoint list as source for displaying Dashboard.
Thanks,
Disha
here is how you assign a value to sharepoint people picker.. http://sharepointforums.blogspot.com/2009/08/adding-value-to-peoplepicker-using-code.html
ReplyDeletehi disha
ReplyDeleteits very urgent
i am getting this error please look in to it.
when publishing the infopath form .am giving correct webserver name but still it is showiing same error .
infopath cannot find or cannot access the following webserver:http:share:2113
make sure that the webserver name is valid ,that your proxy settings are correct,and that you have the necesary
permissions to publish to this library
Hi Ajay
ReplyDeleteCan you please let me know which version of InfoPath are you working on?
You can also follow this Microsoft article: http://support.microsoft.com/kb/925431
When you publish a form to a form library you need to make sure that you have the correct address where you have created the form library.
For example you have form library in http://webserver/sites/test that is the address you put in when publishing the form. I have observed that your server name is incorrect, hope you are giving your server name as “http://share:2113”
Things need to check: you also have the ability to create form library through InfoPath which is recommended also check that you are running InfoPath forms with the user who has proper privileges.
Hope this helps.
Thanks,
Disha Shah
The code is not working for me for some users.
ReplyDeleteSPFieldUserValue fuv = new SPFieldUserValue(SPContext.Current.Web, Convert.ToInt16(entity.EntityData[PeopleEditorEntityDataKeys.UserId]), entity.Description);
When i debug, I found that for some users PeopleEditorEntityDataKeys.UserId is null.
Could you please help me
Susa,
ReplyDeleteAdd this condition before taking fuv value
if (entity.IsResolved == true)
After adding the condition code looks like as following:
SPFieldUserValueCollection values = new SPFieldUserValueCollection();
foreach (PickerEntity entity in userPicker.ResolvedEntities)
{
if (entity.IsResolved == true)
{
SPFieldUserValue fuv = new SPFieldUserValue(SPContext.Current.Web, Convert.ToInt16(entity.EntityData[PeopleEditorEntityDataKeys.UserId]), entity.Description);
values.Add(fuv);
}
}
UserId is null because one possibility is that users are not part of your SharePoint application means they are not added in People who can access the site.
Hope this helps,
Disha Shah
Hi Disha
ReplyDeletei have one unique requirement, do you know can we use People picker contral on custom ASP.NET page using Visual Studio 2005/2008?.
-Jimmy
Jimmy
ReplyDeleteYou want to create ASP.NET Custom page for SharePoint site? If yes you need to add 2 tags in your .aspx page
1> Register Tagprefix="SharePoint"
Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint, Version=12.0.0.0,
Culture=neutral, PublicKeyToken=71e9bce111e9429c"
2> wssawc:PeopleEditor
AllowEmpty="true" Width="70%" ShowEntityDisplayTextInTextBox="true"
ValidatorEnabled="true"
id="userPicker" CssClass="drpClass"
runat="server" CommaSeparatedAccounts=","
ShowCreateButtonInActiveDirectoryAccountCreationMode="true"
SelectionSet="User"
and to get and save data to people picker you can refer the blog.
Hope this helps!!!
NOTE: I did not use some characters because it does not accept and behaves unexpectedly , I hope you can identify and put starting and closing end to both lines.
Thanks
Disha Shah
I'd like to mention that your code resolved an issue I had about non admin users being unable to add a listitem containing a people field using the "EnsureUser" syntax. Using the "SPFieldUserValue" collection and assigning values using the "PeopleEditorEntityDataKeys" class resolved it. Thanks!
ReplyDeleteChetan
ReplyDeleteIt is good to hear that this blog helps you out to solve your problem. Thanks for your time to leave comment and appreciation
Thanks
Disha Shah
I have created one site in sharepoint in this poeple and group picker does not getting some of user of our domain.
ReplyDeleteBut at the default sharepoint site all user come in people and group picker.
please help
Altaf
ReplyDeleteCan you please elaborate your question in more detail? When and What are you doing so that you have knowledge that People Picker does not show all users in that Sharepoint Site.
Just one guess.
Please check the People Picker Column Settings, that you selected all Users or SharePoint Group?
Best Regards
Disha Shah
Very very helpful
ReplyDeleteHi Disha, great work
ReplyDeletewell, I kinda have the same question here, I ve been trying to set the people picker in a form as readonly, because I want my user to see the values I prepopulated it with, but I dont want them to change it....
do you have a solution for this problem??? I have tried many different solutions, but nothing works for people picker.
Hi Manuel
ReplyDeleteThanks for valuable comment.
You can use enabled property of peopleeditor and set as "false" , I tried and everything is working the way you want. Browse button is also disabled.
Hope this helps
Disha Shah
Hi Disha,
ReplyDeleteThanks a lot for sharing this article, its fulfill my project requirement .
thanks once again.
Regards
Mansoor
Hi Disha,
ReplyDeletecan you help on my requirement, that is Cascading drop down list.the below link exact same as my requirement.but
http://datacogs.com/datablogs/archive/2007/08/26/641.aspx
when i change the list names and column names instead of countries,cities,country,city it wont work ?
any suggestion plz...! waiting ur reply..
Regards
Mansoor
Hi Mansoor
ReplyDeleteThanks for appreaciation about blog.
Can you please let me know about what error is given by the code when you change with the Field and list names? So it will be helpful for me to solve out the error.
Thanks & Regards
Disha Shah
Hi Disha,
ReplyDeletecan you help on my requirement, that is SharePoint Desginer to send an attachement to users.I googled this requirement but not getting my requirement.
please help me this requiremnt ,
thanks in advance
any suggestion plz…! waiting ur reply..
Thanks & Regard
vinesh
hi disha,
ReplyDeletei am creating a task list but not using object code. i ve a manager field in the list which is people picker control . i have one more dropdown list where approve is one of the option. my requirement is only manager should approve the form. so i need to compare manager with current user. can u please suggest me some code and pls tel me where do i insert that code..
Hi
ReplyDeleteCan you please let me know when manager should approve the form? He got that information via email or what?
It helps me to provide you the correct answer if you give me full description of the requirement.
Thanks
Disha Shah
Hi Disha,
ReplyDeleteI have one people picker cotrol on my SharePoint Form. I just want to set and get the value from that people picker control
I need to do this on event handler using c# code .
any idea ?
Hi
ReplyDeleteYes you can do that in event handler code too in C#.
The code which is inside the Post, you can use in event handler with changes depends on your event handler eventtype and some properties.
Thanks
Disha Shah
Hi Disha,
ReplyDeleteIts Nice article.
But i m new with the infopath.
and i will tell you the my sinario that i have to implement.
i have design the infopath form which consist of person picker control. Now i want to send this value to "Assign To" column of sharepoint list.(the data type of Assign To is Person picker)
Can u mail me the step by step procedure to achive this.
Thanks
Ujwal
Hi Ujwal
ReplyDeleteIn Inforpath ,We can use ContactSelector which has same kind of functionality as People Picker control in SharePoint.
There are some links which are really very useful
http://www.sharepointassist.com/2009/02/27/adding-a-contact-selectorpeople-picker-to-an-infopath-form/
Please go through with the below link which gives you nice overview for PeoplePicker control with the use of Activex Control
http://metahat.blogspot.com/2007/05/people-picker-control-for-infopath-2007.html
If you stuck please let me know!!
Thanks,
Disha Shah
Hi Disha,
ReplyDeleteThanks very much to share the knowledge with us.
It helps me a lot.
I have one question.
I have one shareport list and there is one column called 'Manager' in that list. The type of this column is 'Single line of text'. Now i want to change the column type to 'Person or Grou'. But i notced that we cant change the type to Person and Group because the option is not present.
Can you please tell me how can i change the type of column without deleting the column? Or else it is necessary to delete the column?
Thanks again for this blog.
- Kaustubh.
Hi Kaustubh
ReplyDeleteThanks for appreciation. No you do not have any other option rather than deleting that column and create a new one.
Thanks
Disha Shah
Hope might helpful this to you.
ReplyDeletehttp://sharepoint2010learnersworld.blogspot.com/2011/07/how-to-validate-users-in-sharepoints.html
Hi disha,
ReplyDeleteI have created an Issue list with Title, Comments, Assigned To, and Status columns. I want to insert/update a list item to this issue list using Application page.
My questions are:
1. What controls i can use for Status and Assigned To field?
2. How can i populate the values for Status and Assigned To field?
Can you provide some sample code to do this?
Thanks in advance,
Abirami
Abirami
ReplyDeleteYou can use SharePoint Controls to do this , name of sharepoint control is "FormField".
When you use "FormField" sharepoint control, you do not need to worry about which type of control you will put, it will automatically take care of this.
Some lines of code which might help you...
foreach (SPField field in lst.Fields)
{
////
ListField = new FormField();
ListField.FieldName = field.Title;
ListField.ControlMode = SPControlMode.New;
ListField.ListId = lstCourseCreditRequirements.ID;
ListField.ID = field.Title;
this.Controls.Add(ListField);
////
}
Hope this helps!!!
Disha Shah
Hi Disha ,
ReplyDeleteThanks for the great article..really hekped me a big deal.
Question- Is it possible to use sharepoint to linq to save the values from the people picker to a people column in a sp List
Hi Martin
ReplyDeleteSorry for the late reply.
Yes you can save values from people picker to a people column via SharePoint LINQ.
may be this piece of code may help you
public void AddUserToList()
{
var ctx = new SiteLinqDataContext(WebUrl);
SPUser usr = null;
using (SPSite site = new SPSite(WebUrl))
{
using (SPWeb web = site.OpenWeb())
{
usr = web.EnsureUser("domain\\account ");
}
}
if (usr != null)
{
TaskDemoItem newItem = new TaskDemoItem()
{
AssignToId=usr.ID,
Title="Hello"
};
ctx.TaskDemo.InsertOnSubmit(newItem);
ctx.SubmitChanges();
}
}
Thanks
Disha Shah
Hi Disha,
ReplyDeleteThanks for your detailed sample...plis bear with me, how can I save multiple entries from a peoplepicker to a people column on a sp list
Regards,
Martin
Hi Disha,
ReplyDeleteHoa can i keep the values in People Picker even though the page gets postback.
Hi Mohan
DeleteMay be this link will help you.
http://berg-henry.blogspot.com/2010/04/get-value-of-peoplepicker-during.html
Disha Shah
HI Disha,
ReplyDeleteCan you help me in one requirement
Hi Sudhanshu
DeleteWhat is your requirement?
Please describe!!!
Disha Shah
but plz reply
ReplyDeletesudhanshu.sharma@lntinfotech.com
beautiful, you saved me a lot of time and headache!
ReplyDeleteThats great blog... help me alot... thanks Disha.....
ReplyDeletehi disha
ReplyDeletei have created custom people editor and want to remove Account Name,Department column from picker dialog, here is my people picker code
userSelect = new PeopleEditor();
pickerEntity = new PickerEntity();
userSelect.MultiSelect = true;
userSelect.AllowEmpty = false;
userSelect.AutoPostBack = false;
userSelect.PickerDialogToolTip = "Select the User to get Alerts";
userSelect.PlaceButtonsUnderEntityEditor = true;
userSelect.ID = "PeopleEditor";
userSelect.MaximumEntities = 5;
userSelect.SelectionSet = "User,SecGroup";
userSelect.Rows = 1;
this.Controls.Add(userSelect);
Hi Vishal
DeletePlease check this as refecrence
http://panvega.wordpress.com/2008/02/22/custom-sharepoint-people-picker/
In this blog, at the button click event,check these lines
if (pickEn.IsResolved)
{
builder.AppendLine(pickEn.DisplayText);
builder.AppendLine(pickEn.Description);
builder.AppendLine(Convert.ToString(hstEntityData["DisplayName"]));
//string email = Convert.ToString(hstEntityData["Email"]);
//string loginName = pickEn.Key;
builder.AppendLine(Convert.ToString(hstEntityData["SPUserID"]));
//string department = Convert.ToString(hstEntityData["Department"]);
builder.AppendLine(Convert.ToString(hstEntityData["PrincipalType"]));
//string sIPAddress = Convert.ToString(hstEntityData["SIPAddress"]);
//string title = Convert.ToString(hstEntityData["Title"]);
}
Hope this helps!!
Disha Shah
hey....
ReplyDeleteIm trying to use a people picker control in my own web part... if you had seen sharepoint 2013 there is a people picker control which drops down suggestions when a name is typed..
I want to add a control which would do that..(drop down users names while someone types on it)
i have raised this issue in many places but no didnt get a proper answer...
hope you could help me..
Thankz
Danister
Hi Disha,
ReplyDeleteI have a people Picker control in my List. I am using a timer job to send email to the user who is picked up in the pople picker. If it is of one user i can get like this.
private void GetNameAndEmailFromPeoplePicker(SPListItem mySourceListItem, out String PeoplePicker, out String CCPeoplePicker, out String UserName)
{
PeoplePicker = "";
CCPeoplePicker = "";
UserName = "";
try
{
SPFieldUserValueCollection Users = new SPFieldUserValueCollection(mySiteWeb, Convert.ToString(mySourceListItem["Point of Contact"]));
foreach (SPFieldUserValue User in Users)
{
UserName = User.User.Name;
PeoplePicker = User.User.Email;
}
SPFieldUserValueCollection BCCUsers = new SPFieldUserValueCollection(mySiteWeb, Convert.ToString(mySourceListItem["Backup Point of Contact"]));
foreach (SPFieldUserValue BCCUser in BCCUsers)
{
CCPeoplePicker = BCCUser.User.Email;
}
}
catch (Exception ex)
{
UlsLogs.LogErrorInULS(ex.InnerException.ToString(), TraceSeverity.High);
}
}
Can you please provide me a method or modify this method to reterive multiple users,Active directory group,Sharepoint Group picked up by the people picker control in sharepoint list
Thanks,
Sandy
Hi Santosh
DeleteIsn't my code wokring for taking the users from people picker?
You would use my code to get user name from People Picker and find the user from SPWeb and then use SPUser object to get its Email-ID and attach properties!
Let me know if you have any questions!
Thank You
Disha Shah
Hi,My thoughts on this will differ depending on the purpose of the web page. I my opinion the best Web Design Cochin is a design that will accomplish the page's goal with the least amount cost and time to develop.Thanks........
ReplyDeleteHi Disha
ReplyDeleteHow to display a list column "Assigned To" value Which is a people picker in a grid view.
Thanks
Richa