No item exists at http://xxxx/Common/Forms/EditForm.aspx It may have been deleted or renamed by another user
-
24-12-2020 - |
سؤال
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
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
المحلول
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 ItemAdded
event 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!