Scenario:As per my requirement I need to create a projectrequest form with NEW/Edit/Display
. when I click on the add new item ,the new custom input form which is created using the SP DESIGNER 2013 - say projectrequestnewform, should be populated.
Hence, I have created a custom new form using SP Designer 2013
with custom html controls
, and other JSOM
code for inserting into the splist
,validation using jQuery
, other js files. Below steps been used to populate the projectrequestnewform form.
- Copied the projectrequestnewform into
siteasets library
of mypublishing site collection
- Similarly, copied projectrequesteditform && projectrequestdispform into
siteasets library
- Clicked on the
new item
from thesplist
andedit the page
and added acontent editor web part
to give a link to this projectrequestnewform location:/siteassets/projectrequestnewform.html
- Also the
siteassets library
contains the projectrequestnewform.js file that has theJSOM
code forCRUD operations
on thissplist
.
when the input form projectrequestnewform.html is loaded on the page, it will be filled with many controls like peoplepicker
and dropdowns
populated from a SPGroup
, Textboxes
for entry and having submit,save and cancel functionalities.
when the form's save button is clicked it will simply insert the item into the splist
and when submit button is clicked it will finally trigger some approval workflow
thats created by SP Wokrflow 2013 Template
. This was configured by using SP Designer 2013
+ Workflow Manager
.
Problem: As part of my reuirement, I also need to apply itemlevelpermissions
when this item is inserted/updated. As per my below code,when I applied the itemlevelpermissions feature
, permissions got applied to projectrequestnewform.html thats residing in the siteassets
library instead of the new item
got created in the projectrequest splist
.
Also when my event receiver is triggered, I am getting the access denied error such that, i wont be able to add an item into this list.
Question:
- I am stuck with how an item added eventreceiver thats targetted to apply the new item in the splist got deviated/applied to the permissions of the the projectrequestnewform.html ?
- Does the workflow thats been configured on this
SPList
's when an item is added , influencing theitemadded()
eventhandler ? - can a
splistitem
would be able to handle bothitemadded() eventhandler/receivers
and a SP D worflow ? - or my approach of triggering both itemadded/itemupdated() eventreceiver() for applying permissions on the
item
and trigger an workflow/approval process with multiple tasks simultaneously is NOT ALLOWED as per SharePoint Design ?
Has anyone faced this issue before?
Code:
public override void ItemUpdated(SPItemEventProperties properties)
{
//base.ItemUpdated(properties);
SPUser currUser = properties.Web.CurrentUser;
this.EventFiringEnabled = false;
try
{
// if (properties.ListTitle.ToLower() == NPDListNames.ITEMLEVELPERMISSIONSLIST.ToString())
// {
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPSite CurrentSite = new SPSite(properties.SiteId);
SPWeb CurrentWeb = CurrentSite.OpenWeb(properties.RelativeWebUrl);
SPList CurrentList = CurrentWeb.Lists[properties.ListId];
SPListItem CurrentListItem;
CurrentListItem =
CurrentWeb.Lists[properties.ListId].
GetItemById(properties.ListItem.ID);
if (!CurrentListItem.HasUniqueRoleAssignments)
{
CurrentListItem.BreakRoleInheritance(true);
CurrentWeb.AllowUnsafeUpdates = true;
SPRoleAssignmentCollection SPRoleAssColn = CurrentListItem.RoleAssignments;
for (int i = SPRoleAssColn.Count - 1; i >= 0; i--)
{
SPRoleAssignment roleAssignmentSingle = SPRoleAssColn[i];
System.Type t = roleAssignmentSingle.Member.GetType();
if (t.Name == "SPGroup" || t.Name == "SPUser")
SPRoleAssColn.Remove(i);
}