.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Updating Person/Group Field when Current User Clicks Button

Posted By:      Posted Date: October 07, 2010    Points: 0   Category :SharePoint

Hi all,

Im trying to either add the current user to a multi person/group field or remove them if they are already in the field when they click a button. My code works to decide which button to render on the page - it will show "Add" if the current user is not in the multi person/group field (titled Members) or it will display "Remove" if the current user already exists in the multi person/group field.

My problem is that when the user clicks the button, i want to take the value in the multi person/group field and use XSL string functions to either add/remove the current user to/from the string and push the updated string back into the multi person/group field - This is not working for me. I can reference the correct column with javascript, but it seems the value i get from the person/group column is not just a simple string, its got all sorts of HTML in there. I was hoping just to get a string like, "member1;member2;...). Ive tried changing the field to just display the account (rather than the name with presence), but it still pulls back a huge chunk of code that i cant work with.

Below is my code so far, just to give you an idea - anyone know what im doing wrong?


View Complete Post

More Related Resource Links

Access denied when user clicks refresh BDC column button

Access denied occurs with any non Site Collection Administrator regardless of rights.  It only occurs in this site collections, others they are able to refresh.  In this particular collection they can add a BDC column to a list, edit an item and place/resolve a value in the bdc col; but when they refresh they are given an acess denied.  Any thoughts on what they need read access to?  This goes away if I give site admin privs (dont want to do that) or give them read only access on the web application (dont want to do that either).

Activiate Email forwarding with Person Group Picker field

I have inserted 3 person group picker fiels.  I need to set them up so when a user selects a user, it shoots off an email.  I was told that I can set this up in SP designer via a workflow?  If so, can anyone let me know how to set this up properly? Thanks!  Bill KreuderIm a new MS CRM Consultant that is learing all things CRM. Im very excited about 4.0!!!!

SharePoint 2007 to Access 2007 - Issues grouping by "Person or Group" field type/column

We are on SharePoint 2007 and using Access 2007.  The SharePoint list contains a column called Assigned Person, column type: Person or Group, single selection, displaying only the name 1) When we Open with Access and Export a copy of the data, then create a report from that table, we do not have the option to group on Assigned Person.  2) When we Open with Access and Link to data on the SharePoint site, then create a report from that list, when we group by Assigned Person... The same person has 2 groups - there are is no other grouping or sorts on the list, and i can't locate a correlation to another field to show why they would have to collections for the same person The Person or Group column sorts "from smallest to largest" as though it is a number field. The list is a task/activity tracking system we created custom for our needs.  We want to pull a weekly report, grouped by Assigned Person, but cannot get access to work.  We do not want to resort to anything more complex, as it takes a much longer process to have reports pulled by Chrystal or one of those types of applications.  And we cannot change out the field for something like a Choice column as the list already has a very large amount of content.  Can anyone assist? Is there a setting hiding somewhere that is causing the problem? 

Redirecting to custom page while clicking on the user/group browse button

Hi, i have created a custom visual web part in visual studio 2010 and i deployed it into sharepoint site by creating a new page in my site. The custom page gets the data of users/groups from database and pass the users to the people picker in sharepoint.Here my question i have a document library where we upload document and get the users page popup that consists of people picker and a user/group browse button.when i click on the (book image button)browse button it will redirect to the user and group search page but here i need to replace my custom  user/group search page with the default one so please help me how to redirect to the custom page by clicking on the user/group browse button,and i need to pass the selected users to the people picker text box........please give me some solution whether this can be done or not if possibe please send me the link or some sample code how to do this   thank you.

I need to hide the print button when user clicks print

using vb.net/asp.net 2005.when the user clicks on a linkbutton I am displaying records from my gridview, popping up a new window so that the user can print the records being displayed in the gridview, dvName is the name of the dive that encloses the gridview and gvName is the name of my gridview.The display and print functionality is working fine but the problem is that I am trying to hide the print button from being printed.  When the user clicks on print then all records (good) and the print button (not good) are being printed, here is the javascript that displays the records and the print button.function printDiv(dvName, gvName) { try{ var sOption="toolbar=no,location=no,directories=yes,menubar=no,"; sOption+="scrollbars=yes,width=750,height=600,left=100,top=25"; var countRows = 0; var gridview = document.getElementById(gvName); if(gridview != null) { countRows = gridview.rows.length; if (countRows > 0) { countRows = countRows - 1; } } var sWinHTML = document.getElementById(dvName).innerHTML; var winprint=window.open("","",sOption); winprint.document.open(); winprint.document.write('<html><LINK href=MyStyleSheet.

Custom user selection in Person or Group type column as per other list.

I have two list in the Sahrepoint Foundation 2010 site. 1) Projects with Title and members(Person or Group - multiple selection) 2) Tasks (Team site default)  - added lookup column Projects form the first list (required) Now I want to assign task given users in the projects list. ex. I have users A,B,C,D,E and Two Project P1 and P2 I have defined that P1 project has users A,B,C so task is distributed/assigned between this members, not to D and E I need some validation or lookup which restrict selection or D and E.   Thank you.  

SPView query to find if the current user belongs to a Group


HI All,

I´m trying to write a query for a list view that should return all items if the current user belong to a group. If the user doesn´t belongs to this group, no items should be returned.

So far, I could find many equal examples about using the CAML Membership element in a comparison with an AssignetTo field. But not making a comparison between the current user and a specific Sharepoint Group.

Any suggestions, please?


Programmatically creating a Person or Group type field Textbox (similar to 'Assigned To' field in Ta


In our ASP.NET application created with SharePoint object model, we have a user interface with a Contact Person TextBox, we want this TextBox to be similar to the “Assigned To” filed in out-of-the-box Task List where you can search for a particular site user by typing in his/her name. How can we achieve this functionality programmatically?

Thanks in advance………

filling current user name in people picker field when loading form using javascript


Hello guys,

I am looking is there any way to fill the current user's name in people picker field in newform.aspx using javascript?

If you anything, please let me know 


"Person or Group" Field Default Value



I have a "Person or Group" column being used to indicate an Assigned To value for our application. I would like the value of that column to default to the current user's name - in other words, the person submitting the new list item will be the assignee by default (and has the option to change it).


I tried doing this through SharePoint Designer by placing [Me] in some value attributes, but it's not working.


Is there some way to accomplish this?






Person or group field


I am using SharePoint 2010

I have a list contains a person or group field

I choosed to display the user name of the user but i every time it returns with a null value

i want to know what is the issue and how can i display this value

Note :

i already configured the profile synchronization  

How to assign values to workflow task person or group custom field?

Using visual studio 2008, in createTask_MethodInvoking, I have the following code. RequestFields has the values from the InfoPath form. ApprovingPersons is a person or group field, added to the task list by my custom task content type. I checked the task list associated with the workflow and I see the custom field.

SPUser user;
SPFieldUserValueCollection fuvc = new SPFieldUserValueCollection();
foreach (Contact person in RequestFields.Persons)
      user = workflowProperties.Web.EnsureUser(person.LoginName);
      fuvc.Add(new SPFieldUserValue(workflowProperties.Web, user.ID, user.Name));

// this is the line causing problem, I believe
PreApprovalTask_TaskProperties.ExtendedProperties["ApprovingPersons"] = fuvc;

I got the following error message:

at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] argument



Updating field based on user selection


I have a requirement to update a FormField based on a selected value of a look up FormField. Basically, the look up fleld displays some default values. When users select a deault value, based upon the selection, I want to update another text field with a value stored in a List.

How can I do it using SharePpoint Designer?

Infopath Question: XPath code to remove domain name from AccountID field in Person/Group Picker


I have an infopath email based submission form where I am using the Person/Group picker as a way for people to find people in the active directory to CC the form to. I was using the field "DisplayName" in the control and discovered that when you try to CC several employees, that it would disrupt the rules and you can't send the form.

I want to use the field "AccountID" but it includes the domain before the email alias (for ex. REDMOND\johndoe). Is there a formula code I could use to remove the domain from every email alias. Right now my CC formula is concat(SubmitterAlias, "; ", DisplayName)

Gettin error in Updating user field using object model



I have multiple site collections and I have to update user filed in each site collection for particular user say X to Y.Now the problem is that display name of user X is resolved in different way in different site collection.In some site collection user x shows correct names and items get updated while in some it takes display name as login name and the query which i created fails.

How to resolved this user issue?

Workaround to using "Person or Group" field in a "Calculated" column formula?


Apparently, SharePoint does not allow you to insert a "Person or Group" column into a "Calculated" field's formula.

Is there a workaround to adding a "Person or Group" column into a "Calculated" field's formula?

-Maybe a way of coverting the data from the Person or Group column into a text field, and referencing that text field in the formula?

Microsoft mentions only Columns of the following data types can be referenced in a formula: single line of text, number, currency, date and time, choice, yes/no, and calculated.

SharePoint Problem with Base Field Control Multilookup and Person and Group



I am creating a custom field type. Inside this field type I need to create controls for various SharePoint field types like Number, Single line of text, lookup, multilookup, Preson and Group etc.So I am using SharePoint BaseFieldControl class to generate these controls. It works fine for all field type except for "Multi lookup" and "Person and Group" columns. Normally these controls are working fine but after a post back all the values gets removed and empty controls are shown. Is there any property exists which i need to set to retain values in between post backs??

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend