Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Copy\Move Documents to another library based on column value

$
0
0

Dear All,

I have written ER to copy file from one library to another library, the document/file are moving and metadata (means

column values) are updating if i upload the documents with older extensions like .doc, .xls, .png, .gif etc.

if i use files with extensions like .docx, .xlsx, etc the document/file is moving but metadata (means column values

are not updating.

Below is my code kindly please help me out.

SPList list = web.Lists["Test"]; SPListItem item = properties.ListItem; string name = properties.ListItem["Status"].ToString(); string dept = properties.ListItem["To Department"].ToString(); string desc = properties.ListItem["Description"].ToString(); string comment = properties.ListItem["Comment"].ToString(); string letno = properties.ListItem["Letter No."].ToString(); DateTime date = Convert.ToDateTime(properties.ListItem["Date of Issue"].ToString()); SPUser oUserAuthor = properties.Web.EnsureUser("System Account"); SPUser oUserModified = properties.Web.EnsureUser("System Account"); System.DateTime dtCreated = item.File.TimeCreated; System.DateTime dtModified = item.File.TimeLastModified; if (name == "Approved" && dept == "Sales and Marketing") { Hashtable ht = new Hashtable(); ht.Add("Approval Status", name); ht.Add("Department", dept); ht.Add("Comment", comment); ht.Add("Letter No.", letno); ht.Add("Date of Receiving", date); ht.Add("Summary", desc); SPFile newFile = list.RootFolder.Files.Add(item.File.Name, item.File.OpenBinary(), ht, oUserAuthor, oUserModified, dtCreated, dtModified, true); newFile.Update(); }

i have attached the document for your overview.

Many thanks in advance.

Regards,

Ravi Kumar. S



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>