How to set Owner column as created by?

I have owner column and I want to fill automatically as created by?

How can I do it?

thanks,

Replay

I think you can't do it without code because Created by field is built-in read only field .

but you can update it via event receiver after added or updated using this code if you use default form , if you use custom form as visual web part , don't need to event receiver

SPSite site = new SPSite(siteUrl);

SPWeb web = site.OpenWeb();

web.AllowUnsafeUpdates = true;

SPList list = web.Lists["Test"];

SPListItemCollection collection = list.Items;

foreach (SPListItem item in collection )

{

SPUser user = web.EnsureUser(UserName Login Name);

//1073741823;#System Account   //User name values are in this format ID;#Login Name
string value1 = user.ID + ";#" + user.Name; //Create in same format

item["Author"] = value1; //for Created By field

item["Editor"]=value1 ;  //Modified By field

item.Update();  //Update the item

}

list.Update();

web.Update();

Check also

Category: sharepoint server Time: 2016-07-31 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.284 (s). 12 q(s)