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

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

how to set Afterproperties user field?

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

Hi guys 4

I have a custom list that have a "people person field", I need to set the value on itemAdding event.

But If I set afterproperties filed with SPUser object I recibe and error.

What kind of "data type" I have to assign to afterproperties user field?

do you have any example?

thank in advance



View Complete Post

More Related Resource Links

How to Set a list item's createdby or modifiedby field as a User(deleted from AD)



I have to migrate data from SQL DB to SP list. But its old data and some users who created/modified the record has been deleted from the AD. Now I need to set the CreatedBy / ModifiedBy Field of the item accordingly. How to achieve this?

And when I tried to modify the "Editor" and "Author" field through Object Model, it works. But its not working through Webservice. What is the reason behind this?

Please help me find an optimal solution for this...


Thanks and Regards,

/* John JB */

User Specific Values for a Drop Down "Choice" Field

I would like to create a drop down field which has some fields disabled or not visible based on the user logged in.  Is this possible?

Active Directory User validation field in ASP.NET


I like to add a field that add active directory user in ASP.NET Web Application .




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 


Updating Person/Group Field when Current User Clicks Button


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?


User Profile working, but domain in the Account Name field is incorrect


Profile import is working with a small set of users from just one OU. The synchronization connection has a Forest Name of "corp.mycompany.com", just like in our current profile settings in MOSS 07.

However, the user profiles created are listed with "corp" as the domain, not "mycompany".

E.g. my profile Account Name shows "corp\eriehl", but it should be "mycompany\eriehl".

How do I update this reserved property to contain the correct value for our domain?

Problem in properties.AfterProperties with respect to DateTime field.

Hi all,

I have an event handler, ItemAdding and I am trying to get start and end for "Calendar List".

For,  StartDate = Convert.ToDateTime(properties.AfterProperties["EventDate"]); its showing next day.
For e.g, User took 5 day vacation from 12 Jan to 16 Jan. But for StartDate its showing 13 Jan and also for end date i.e. 17th.

I tried some reserach on about this issue: 

But in my case, properties.ListItem is null.
SPListItem currentItem = properties.ListItem;
DateTime beforeValue = System.Convert.ToDateTime(currentItem.Fields[displayName].GetFieldValueForEdit(currentItem[displayName]));
properties.AfterProperties[internalFieldName] = SPUtility.CreateISO8601DateTimeFromSystemDateTime(beforeValue.AddDays(1)).ToString();

This is my complete code for ItemAdding

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?

Resolve AD names to Display names in SharepointDesigner Workflow emails for multiple user field



Is there a way I can resolve multiple users in a "People and Group" field to thier display name rather than Ad name in sharepoint when doing a designer workflow . The workflows job is send the mail to the business owners and request request that a certain permission be granted to User A, UserB, User C,...and so on.

SPD activities Linktitle action to my understanding only resolves a single user.





how to automaticly put user names in a template field



I am using the helpdesk template from microsoft, and when users are requesting a service request I would like to have their name automatically apear in customer field, is there a way to do this?

server windows 2003 r2

sharepoint services 3.0


Eric Hendrickson

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?

Empty field on Alert Notification email sent to user when they add an 'Alert Me'




I'm trying to figure out the empty field that should be populated in the email that a user receives when adding an alert. The missing field is the bit in single quotes that is blank. I have added a link to a screenshot below as well.

What is the source of this field? Any ideas why it is blank?


thanks in advance.


Alert 'xxx' has successfully been added on '' .

You will receive alerts in e-mail. The timing and criteria for the alerts depend on the settings entered when the alert was added.

You can change this alert or any of your other alerts on the My Alerts on this Site page.



How do you set the ClassInfo of a user creatable custom field type?

I have implemented a custom field type class that is user creatable, and derives from SPComputedField as a base class. This means it gets rendered in a <td class="ms-vb2"> cell in the list. I want to change it to render with the ms-vb-title class. If I were defining a fixed instance of my custom field in a list or content type, then this could be done in the <Field> element of the content type or list definition XML by setting the ClassInfo property.

However, how do I achieve this when the field is user creatable and the user adds an instance of the field to the list through the GUI? Is there a way for custom fields to specify their default class info, or to otherwise override the class of the cell they are rendered within in a view?

Edit: To answer my own question, adding the following to the 3-argument constructor works, but is nasty and unsupported. I'd still like a clean way of achieving this.

public MyCustomField(SPFieldCollection fields, string typeName, string displayName)
            : base(fields, typeName, displayName)
  MethodInfo miSetFieldAttributeValue = this.GetType().GetMethod("SetFieldAttributeValue", BindingFlags.Instance | BindingFlags.NonPublic);
  miSetFieldAttributeValue.Invoke(this, new object[] { "ClassInfo", "Menu" });

How to display a user's department in another field



I have created an infopath form with a UserPicker Field. Just under that field is a textbox where I would like to display the department of whatever user was selected in yeh userpicker field. I have tried connecting to the getuserprofilebyname webservice, but it seems only to reflect the current user's details.

Is there any way of reflecting this information? All details are captured in AD and I would really like to keep it only in AD

Thanks in advance

MS SQL Server: Disconnect Users From Database - Kill User Session

If you ever wanted to restore your database from a SQL backup file (.bak), but there are still users connected to your database, the backup operation will fail causing the error: Exclusive access could not be obtained because the database is in use.

Choosing Between a User Control or Web Part for SharePoint

SharePoint will only display Web Parts on a page. However, there are publicly available shims that allow you to write user controls and have them be displayed as a Web Part. From SharePoint's point of view, the shim is a Web Part. From the point of view of the user control, the shim is simply a control in .NET that is including the user control

Creating Sites/Lists/List Items under Current User Context in SharePoint By Using SPUserToken

Usually we do this by performing the action under RunWithElevatedPrivileges method and updating the listitem using SPListItem.SystemUpdate() method (see here). but this approach has its own flaws like (RunWithElevatedPrivileges will run under system account, we cannot use SystemUpdate for SPSite,SPWeb,SPList, since it runs under system we will "CreatedBy" by as SystemAccount).
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