Click here to Skip to main content
15,893,266 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,

I am using SharePoint 2010. In SharePoint site there is a Form Library which has column "Current Date". I want to create a timer job which will update this column with current system date once in a day.
I know this is possible with SharePoint list with following code:
================================================================
C#
SPList shippingList = oSPWeb.Lists["Candidate Info"];
    SPQuery listQuery = new SPQuery();
    listQuery.Query = "<where><isnotnull><fieldref name="Title" /></isnotnull></where>";

    SPListItemCollection Items = shippingList.GetItems(listQuery);

    if (Items.Count > 0)
    {
        foreach (SPListItem item in Items)
        {
            SPListItem itemToUpdate = shippingList.GetItemById(item.ID);

            itemToUpdate["Current Date"] = DateTime.Now;
            itemToUpdate.Update();
         }
     }

================================================================
But this code is not working with me for SP Form Library. Is anything missing in above code, or is any other way to achieve the above requirement.

Thanks,
Prasanna
Posted
Updated 7-May-13 20:49pm
v2
Comments
pykos 8-May-13 3:15am    
Are you shure your query returns elements? Does it throw any exceptions?

Maybe you can try with this...

site.WebApplication.FormDigestSettings.Enabled = false;
site.AllowUnsafeUpdates = true;
///code here;
site.WebApplication.FormDigestSettings.Enabled = true;
site.AllowUnsafeUpdates = false;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900