Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

So I have this really simple function which updates a couple of fields on two different lists (one is a document library) The thing is on the document library does not updates any of the fields I need to update.

Here's the code

public void Approval(int id, string comment, bool result)

            string ownerLibraryName = string.Empty;
            string targetUserName = string.Empty;
            int targetId = 0;
            string userName = string.Empty;

            userName = SPContext.Current.Web.CurrentUser.Name;
            string userLibraryName = SPContext.Current.Web.CurrentUser.LoginName.GetUserWithOutDomain();

                using (SPSite noSecuritySite = new SPSite(SPContext.Current.Site.Url))
                    noSecuritySite.AllowUnsafeUpdates = true;
                    using (SPWeb noSecurityWeb = noSecuritySite.OpenWeb())
                        noSecuritySite.AllowUnsafeUpdates = true;
                        SPList userLibrary = noSecurityWeb.Lists.TryGetList(userLibraryName);
                        if (userLibrary == null) { throw new Exception(string.Format("La biblioteca {0} no existe", userLibraryName)); }

                        SPListItem voboRequest = userLibrary.GetItemById(id);

                        targetId = int.Parse((voboRequest[CustomSiteColumns.FIELD_VOBO_ID].ToString()));
                        SPFieldUserValue docOwner = new SPFieldUserValue(voboRequest.Web, voboRequest[CustomSiteColumns.FIELD_VOBO_DOC_OWNER].ToString());
                        ownerLibraryName = docOwner.User.LoginName.GetUserWithOutDomain();    

                        voboRequest[CustomSiteColumns.FIELD_CURRENT_ACTION] = "MoveTo";

                        noSecurityWeb.AllowUnsafeUpdates = true;
                        SPList docOwnerLibrary = noSecurityWeb.Lists.TryGetList(ownerLibraryName);
                        if (docOwnerLibrary == null) { throw new Exception(string.Format("La biblioteca {0} no existe", ownerLibraryName)); }

                        SPListItem targetDoc = docOwnerLibrary.GetItemById(targetId);                        
                        targetDoc[CustomSiteColumns.FIELD_ARCHIVE_RESPONSE] = comment;
                        targetDoc[CustomSiteColumns.FIELD_ARCHIVE_APPROVAL] = result;

                        targetDoc.Log(string.Empty, DateTime.Now, result ? Support.Enums.TraceableOperation.Aprobado : Support.Enums.TraceableOperation.Rechazado, userName, comment);

                        noSecurityWeb.AllowUnsafeUpdates = false;
                    noSecuritySite.AllowUnsafeUpdates = false;

If I check the targetDoc[CustomSiteColumns.FIELD_ARCHIVE_RESPONSE] field after the targetDoc.Update(), I get a null value, but if I check the voboRequest[CustomSiteColumns.FIELD_CURRENT_ACTION] value after the voboRequest.Update() I get a 'MoveTo', which is precisely the value I just assigned.

Any ideas what might be happening?

share|improve this question
I hesitate to post this as an answer because I can't provide a lot of evidence to back it up, but perhaps you need an SPList.Update() in there too. – thanby Feb 18 '13 at 16:23
Its kinda strange because it was working before. I just deleted the site collection and I'm re-running the SharePoint config wizard. I'll try it out when I finish the wizard and the site re-deployment – Jaime Feb 18 '13 at 16:27
i have the same error, how do yor resolver this problem? – user17542 Jun 10 '13 at 20:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.