1

When I am trying to apply an item level permissions for a uploaded document in my document library am getting the error:

No item exists at http://xxxx/Common/Forms/EditForm.aspx?Mode=Upload&CheckInComment=&ID=170&RootFolder=/Common/KnowledgeDocuments&IsDlg=1. It may have been deleted or renamed by another user

am able to upload the document but am getting this ugly yellow error!

No item exists at http://xxxx/Common/Forms/EditForm.aspx It may have been deleted or renamed by another user

eror-inuplaodingadocinfolder1

        List<String> objlistofGroupNames = new List<string>();

        SPListItemCollection pconfigILPItemCollection = null;
        try
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                SPSite CurrentSite = new SPSite(paramProperties.SiteId);
                SPWeb CurrentWeb = 
      CurrentSite.OpenWeb(paramProperties.RelativeWebUrl);
                CurrentWeb.AllowUnsafeUpdates = true;
                SPList configCurrentList = 
  CurrentWeb.Lists.TryGetList(NPDListNames.ITEMLEVELPERMISSIONSLIST);

                SPQuery objquery = new SPQuery();

                foreach (SPListItem singleItemConfigList in 
          configCurrentList.Items)
                      {
                      if (singleItemConfigList != null && 
              singleItemConfigList.ListItems.Count > 0)
                      {
                        string strEntityConfigList = 
              singleItemConfigList["Entity"].ToString();  //Common|Others

      if (!pCurrentListItem.HasUniqueRoleAssignments)
                                        {
                 pCurrentListItem.BreakRoleInheritance(false);
                        CurrentWeb.AllowUnsafeUpdates = true;
          SPRoleAssignmentCollection SPRoleAssColn = 
                  pCurrentListItem.RoleAssignments;
                                            for (int i = SPRoleAssColn.Count 
                              - 1; i >= 0; i--)
            SPRoleAssignment roleAssignmentSingle = SPRoleAssColn[i];
           System.Type t = roleAssignmentSingle.Member.GetType();
                                                //    continue;
                                                //if (roleAssignmentSingle.Member.LoginName == properties.UserLoginName)
                                                //   continue; 
                  SHAREPOINT\\system
                                               //if 
          (roleAssignmentSingle.Member.LoginName != "SHAREPOINT\\system" ||  
         roleAssignmentSingle.Member.ID != npdadminSPGroup.ID || 
        roleAssignmentSingle.Member.LoginName != 
              paramProperties.UserLoginName)
                                              if 
              (roleAssignmentSingle.Member.Name != "System Account" && 
              roleAssignmentSingle.Member.LoginName != 
                          paramProperties.UserLoginName)
                  {
                   if (t.Name == "SPGroup" || t.Name == "SPUser")
                         sPRoleAssColn.Remove(i);                                                    
                     }                        
 }

                          try
                          {
                           if 
          (!singlestrReadILPGroupName.ToLower().Contains("creator") && 
              !string.IsNullOrEmpty(singlestrReadILPGroupName))  //non-
           //author  /sp group permissions
                {
             SPGroup singleSPGroup = 
              pCurrentWeb.SiteGroups[singlestrReadILPGroupName];
       SPRoleAssignment mroleAssignmentEditNoDelILP = new 
       SPRoleAssignment(singleSPGroup);
      SPRoleDefinition mroleDefinitionEditNoDelILP = 
           pCurrentWeb.RoleDefinitions["NPD ReadILP"];

        mroleAssignmentEditNoDelILP.RoleDefinitionBindings.Add(
         mroleDefinitionEditNoDelILP);
       pCurrentListItem.RoleAssignments.Add
          (mroleAssignmentEditNoDelILP);
   singlestrReadILPGroupName.ToLower().Contains("creator") && 
       !string.IsNullOrEmpty(singlestrReadILPGroupName)) ///author 
        //permissions <p>
        at last am doing  <p>
             pCurrentListItem.SystemUpdate(false);  

Please understand that, my document library's versioning settings are set to Create Major Versions [ NOT MINOR VERSIONS] and Require document to be checked out is set to NO

  • Is it an event receiver? right? which event are you using? Is it item added?! – Mohamed El-Qassas MVP Jun 13 '17 at 16:23
  • Yes of course, its an item eventreceiver on a doc lib, with itemadded ,itemupdated event handlers. – userAZLogicApps Jun 13 '17 at 16:41
  • where this code specifically ? in itemadded or itemupdated – Mohamed El-Qassas MVP Jun 13 '17 at 16:42
  • its added in itmadded() event handler . and similar code been added with few changes but with a different set of permissions [ different sp groups ] on the itemupdated event handler . also would like to mention that, i have created custom permissions levels as well, like contributenodelete, DesignWithoutEditItems etc . these permissions were applied to the sp groups when item is updated – userAZLogicApps Jun 13 '17 at 18:07
  • 1
    Try to add your code (set document permission) only at ItemUpdated or ItemUpdating to can catch the document properties, then set its permission! hope it working! – Mohamed El-Qassas MVP Jun 13 '17 at 18:47
1

Try to debug your event receiver and you will note that this error raised from the itemAdded event, because the metadata is not available in the ItemAddedevent and this cause

No item exists. It may have been deleted or renamed by another user

So Make sure that you have added your code (set document permission) only at ItemUpdated or ItemUpdating to can catch the document properties, then set its permission!

  • unfortunately there are no metadata - custom fields available or i have created in my doc lib. its plain doc lib, with default columns - modfiied, modified by, created etc. end user will simply add the document for sharing with others and other group members will be getting the read/contributenodelete permissions – userAZLogicApps Jun 17 '17 at 17:45
  • 1
    I have tested with itemupdated method ONLY, based on your suggestion , and it seems working for 2 docu libs. i am having soem 14 doc libs with item level permissions applied with several different groups having contribute, edit, read permissions. am testing again n with multiple doc libs . if there exists any issues , will update here, – userAZLogicApps Jun 17 '17 at 19:57
  • 1
    Great job :) , of course, updating me in case, you face related issue! – Mohamed El-Qassas MVP Jun 17 '17 at 20:18
  • it would be great , if you can help me, by spending few minutes for some of the other doubts i have raised few minutes before. related to search, re-index the list/doclib . :-) – userAZLogicApps Jun 17 '17 at 20:39
  • Sure, provide me the Quest URL, Hope I can help! – Mohamed El-Qassas MVP Jun 18 '17 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.