Error in event receiver

Hi Friends, mails from SAP are sent to HR users from WF-BATCH.The users are unaware why the message have been sent.
The message that is being sent is given below:
Messages received from: Batch WF-BATCH
Subject: Error in event receiver
Body of message:
Error processing following event linkage:
KNA1 STATUSCHANGE WORKITEM
Following error occurred:
WL 605
000003807054
Message text:
Work item 000003807054 locked by user (enqueue error)
Event container appended as attachment.
Event linkage not changed.
Event stored temporarily.
Events can be redelivered via event queue
administration (transaction SWEQADM).
Kindly help.

Hi,
Please refer the link [Workflow System Administrator Role|http://help.sap.com/saphelp_nw70ehp2/helpdata/en/8c/1923ce932b11d2a5ea0060087a79ea/content.htm] - The administrator needs to be assigned with these roles mentioned in this hellp documentation.
The error message in your case indicates that there is some problem in the "Event Linkage". KNA1 is the Customer Master Table. I guess it is the "STATUSCHAGED" event of Customer Object is having some event linkage problem. You can check the event type linkages in SWETYPV Transaction. Thanks.
Regards
Suresh

Similar Messages

  • Workflow inbox level  given  message Error in event receiver .

    hi guys,
    workflow standard  purchase order copy to custom and create to purchase order event will be triggered successfully.but inbox level this errors has come but not display the purchaser order please help to me:
    Error in event receiver
    Error processing following event linkage:
    BUS2012 RELEASESTEPCREATED WS90000015
    Following error occurred:
    SWF_RUN 594
    Thanks&Regards,
    Bikshapathi.

    Hi BP,
    are you using any rule in your WF?
    check if binding is proper,
    check if you passing PO parameters properlty, as ReleaseCode would be a mandatory field in your WF/task container.
    Hope it helps.
    Aditya

  • Error in event receiver in workflow for PO release strategy

    Hi Expert,
    I am trying to trigger an email through workflow for PO release. I have setup following
    In SWETYPV,I have check marked on Type linkage active and Enable event queue. Status no error.
    In PFTC, under Triggering events, Object type BUS2012 is green light
    When i create the PO in my SAP inbox, i get notification, however, i getting this error u201CERROR IN EVENT RECEIVER".
    Also, how can i send the notification to the user's outlook inbox? Your help will be appreciated.

    laurarice wrote:
    Hi Expert,
    >
    > I am trying to trigger an email through workflow for PO release. I have setup following
    >
    > In SWETYPV,I have check marked on Type linkage active and Enable event queue. Status no error.
    > In PFTC, under Triggering events, Object type BUS2012 is green light
    > When i create the PO in my SAP inbox, i get notification, however, i getting this error u201CERROR IN EVENT RECEIVER".
    > Also, how can i send the notification to the user's outlook inbox? Your help will be appreciated.
    I suppose, you are using the workflow WS20000075. Add sending email as an additional task to the same workflow in SWDD.

  • Error in event receiver  Archivelink Service Pack 20

    We implemented Archive link 3 years ago and for the first year, I was constantly bombarded with enqueue errors from  background steps that attach images to documents.  The images were always attached fine so these were just a nuisance. 
    At some point, a service pack must have fixed this because they just stopped happening two years ago.
    Over the weekend, we upgraded to SP 22 and now the enqueue error are back with a vengeance =(
    I get 40-50 of these per day now and it's blowing up my SBWP inbox:
    Error processing following event linkage:
    IMAGE ASSIGNED WORKITEM
    Following error occurred:
    WL 605
    000003975171
    VIC17629
    Message text:
    Work item 000003975171 locked by user VIC17629 (enqueue error)
    Event container appended as attachment.
    Event linkage not changed.
    Event stored temporarily.
    Events can be redelivered via event queue
    administration (transaction SWEQADM).

    Check with some OSS notes.
    Thanks
    Arghadip

  • SharePoint 2013 event receiver error

    I am currently working on a SharePoint online project. I am facing a strange issue. My code generates 6 documents
    in 6 different document libraries along with other metadata. When I save data to a List, the event receiver fires and creates all the 6 documents. But sometimes it stops creating the 6 documents and left with 1 or 2 documents. Sometimes documents has been
    created but without any metadata. The same code is working fine in my on-premises environment, but it sometimes breaks in the Office 365 environment. I also created a log list to track the issue as we cannot debug in Office 365. In the log list I found a error
    message saying "Thread was being aborted." Below is my code. please help it is happening only in Office 365 environment.
    using Microsoft.SharePoint;
    /// <summary>
    /// List Item Events
    /// </summary>
    public class ExcelGenReceiver : SPItemEventReceiver
    /// <summary>
    /// The template URL
    /// </summary>
    private const string TemplateUrl = "/Quotation Analysis Electrical/Forms/Quotation Analysis Sheet ELEC_Blank.xlsm";
    /// <summary>
    /// The template url1
    /// </summary>
    private const string TemplateUrl1 = "/Quotation Analysis Mechanical/Forms/Quotation Analysis Sheet MECH_Blank.xlsm";
    /// <summary>
    /// The template url2
    /// </summary>
    private const string TemplateUrl2 = "/TenderSummaryLib/Forms/TenderSummaryBlankMaster1.xlsm";
    /// <summary>
    /// The RFI template URL
    /// </summary>
    private const string RfiTemplateUrl = "/EstimatingRFI/Forms/RFI Schedule MASTER.docx";
    /// <summary>
    /// The drawing template URL
    /// </summary>
    private const string DrawingTemplateUrl = "/Tender and Drawing Schedule/Forms/Tender Document Drawing Schedule.docx";
    /// <summary>
    /// The tender return template URL
    /// </summary>
    private const string TenderReturnTemplateUrl = "/Est_Tender_Pricing_Document/Forms/Tender Pricing Document blank.xlsm";
    /// <summary>
    /// The project number
    /// </summary>
    private string projectNumber = string.Empty;
    /// <summary>
    /// The project name
    /// </summary>
    private string projectName = string.Empty;
    /// <summary>
    /// The no bid
    /// </summary>
    private string noBid;
    /// <summary>
    /// The team
    /// </summary>
    private string team;
    /// <summary>
    /// The description
    /// </summary>
    private string description;
    /// <summary>
    /// The status
    /// </summary>
    private string status;
    /// <summary>
    /// The electrical
    /// </summary>
    private SPUser electrical;
    /// <summary>
    /// The mechanical
    /// </summary>
    private SPUser mechanical;
    /// <summary>
    /// The document date
    /// </summary>
    private DateTime? docDate;
    /// <summary>
    /// The tender received
    /// </summary>
    private DateTime? tenderReceived;
    /// <summary>
    /// The tender return
    /// </summary>
    private DateTime? tenderReturn;
    /// <summary>
    /// The pre construction program start date
    /// </summary>
    private DateTime? preConstructionProgramStart;
    /// <summary>
    /// The pre construction program end date
    /// </summary>
    private DateTime? preConstructionProgramEnd;
    /// <summary>
    /// The sector
    /// </summary>
    private string sector;
    /// <summary>
    /// The design build
    /// </summary>
    private string designBuild;
    /// <summary>
    /// The build type
    /// </summary>
    private string buildType;
    /// <summary>
    /// The service program start date
    /// </summary>
    private DateTime? serviceProgramStart;
    /// <summary>
    /// The service program completion date
    /// </summary>
    private DateTime? serviceProgramCompletion;
    /// <summary>
    /// The client1
    /// </summary>
    private string client1;
    /// <summary>
    /// The client2
    /// </summary>
    private string client2;
    /// <summary>
    /// The client3
    /// </summary>
    private string client3;
    /// <summary>
    /// The client4
    /// </summary>
    private string client4;
    /// <summary>
    /// The consultant
    /// </summary>
    private string consultant;
    /// <summary>
    /// An item is being added.
    /// </summary>
    /// <param name="properties">The Item Event properties</param>
    public override void ItemAdded(SPItemEventProperties properties)
    //this.EventFiringEnabled = false;
    var web = properties.Web;
    var listItem = properties.ListItem;
    try
    LogIssue(web, null, "Item Added", "List Item Id {0}", listItem.ID);
    if (!this.AttemptCopyProcess(listItem))
    LogIssue(web, null, "List Id : " + listItem.ID, "AttemptCopyProcess failed.");
    catch (Exception ex)
    LogIssue(web, ex, "List Id : " + listItem.ID, "AttemptCopyProcess failed.");
    finally
    //this.EventFiringEnabled = true;
    LogIssue(web, null, "List Id : " + listItem.ID, "Event Receiver completed sucessfully.");
    /// <summary>
    /// Logs any issues found
    /// </summary>
    /// <param name="webContext">The web context.</param>
    /// <param name="exception">The exception, if null not exception details are written</param>
    /// <param name="contextId">The context identifier, a unique identifier that allows us to know where the call originated, i.e. a List and ListItem Id, or a Page Url</param>
    /// <param name="comment">The comment.</param>
    /// <param name="args">The arguments.</param>
    private static void LogIssue(SPWeb webContext, Exception exception, string contextId, string comment, params object[] args)
    //// if (webContext.AllProperties.ContainsKey("EnableLogging"))
    var list = webContext.Lists.TryGetList("ErrorIssues");
    if (list != null)
    var item = list.AddItem();
    item["Title"] = contextId;
    if (exception != null)
    item["Message"] = exception.Message;
    item["InnerException"] = exception.InnerException ?? (object)string.Empty;
    item["StackTrace"] = exception.StackTrace;
    if (!string.IsNullOrEmpty(comment))
    item["Comment"] = string.Format(comment, args);
    item.Update();
    /// <summary>
    /// Assigns the field.
    /// </summary>
    /// <param name="listItem">The list item.</param>
    /// <param name="fieldName">Name of the field.</param>
    /// <param name="contextId">The context identifier.</param>
    /// <returns>The fields string value if present, otherwise string.empty.</returns>
    private static string AssignField(SPListItem listItem, string fieldName, string contextId)
    var fieldValue = string.Empty;
    if (listItem.Fields.ContainsField(fieldName) && listItem[fieldName] != null)
    fieldValue = listItem[fieldName].ToString();
    else
    LogIssue(listItem.Web, null, contextId, string.Format("Field not available : {0}", fieldName));
    return fieldValue;
    /// <summary>
    /// Assigns the field as a DateTime
    /// </summary>
    /// <param name="listItem">The list item.</param>
    /// <param name="fieldName">Name of the field.</param>
    /// <param name="contextId">The context identifier.</param>
    /// <returns>Returns the date if found, otherwise returns DateTime.MinValue</returns>
    private static DateTime? AssignDateField(SPListItem listItem, string fieldName, string contextId)
    DateTime? fieldValue = null;
    if (listItem.Fields.ContainsField(fieldName) && listItem[fieldName] != null)
    fieldValue = Convert.ToDateTime(listItem[fieldName].ToString());
    else
    LogIssue(listItem.Web, null, contextId, string.Format("Field not available : {0}", fieldName));
    return fieldValue;
    /// <summary>
    /// Creates the folder.
    /// </summary>
    /// <param name="listdoc">The list.</param>
    /// <param name="folderName">Name of the folder.</param>
    private static void CreateFolder(SPList listdoc, string folderName)
    LogIssue(listdoc.ParentWeb, null, "List Id : " + listdoc.ID, "Creating folder {0} in {1}", folderName, listdoc.RootFolder.ServerRelativeUrl);
    // Updated by Indusnet
    SPListItem folder1 = listdoc.Items.Add(listdoc.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder);
    folder1["Name"] = folderName;
    folder1.Update();
    listdoc.Update();
    // End Updated
    /// <summary>
    /// Assigns the user field.
    /// </summary>
    /// <param name="listItem">The list item.</param>
    /// <param name="fieldName">Name of the field.</param>
    /// <param name="contextId">The context identifier.</param>
    /// <returns>Returns the user if found, otherwise null.</returns>
    private static SPUser AssignUserField(SPListItem listItem, string fieldName, string contextId)
    SPUser user = null;
    if (listItem.Fields.ContainsField(fieldName) && listItem[fieldName] != null)
    var userField = (SPFieldUser)listItem.Fields.GetField(fieldName);
    var fieldValue = (SPFieldUserValue)userField.GetFieldValue(listItem["electrical_proj_manager"].ToString());
    user = fieldValue.User;
    else
    LogIssue(listItem.Web, null, contextId, string.Format("Field not available : {0}", fieldName));
    return user;
    /// <summary>
    /// Attempts the copy process.
    /// </summary>
    /// <param name="listItem">The list item.</param>
    /// <returns>True if it successfully processed, false otherwise.</returns>
    private bool AttemptCopyProcess(SPListItem listItem)
    if (listItem.ParentList.Title != "Enquiry_Template")
    LogIssue(listItem.Web, null, "List Id : " + listItem.ID, "ListItem titles is not Enquiry_Template, aborting.");
    return false;
    var finalNum = "15-" + new Random().Next(0, 9999).ToString("D4");
    this.Initialize(listItem, finalNum);
    if (this.noBid != "Yes")
    LogIssue(listItem.Web, null, "List Id : " + listItem.ID, "The noBid field does not equal Yes, aborting.");
    return false;
    this.CopyFiles(listItem.Web, finalNum);
    this.CreateFolders(listItem.Web);
    return true;
    /// <summary>
    /// Copies the files.
    /// </summary>
    /// <param name="web">The web.</param>
    /// <param name="finalNum">The final number.</param>
    private void CopyFiles(SPWeb web, string finalNum)
    LogIssue(web, null, "Web Id : " + web.ID, "Setting the copying of files ...");
    var mechanicalQuoteList = web.Lists["Quotation Analysis Mechanical"];
    var electricalQuoteList = web.Lists["Quotation Analysis Electrical"];
    var tenderSummarList = web.Lists["TenderSummaryLib"];
    var estimatingList = web.Lists["EstimatingRFI"];
    var tenderSheduleList = web.Lists["Tender and Drawing Schedule"];
    var tenderPricingList = web.Lists["Est_Tender_Pricing_Document"];
    var url1 = mechanicalQuoteList.RootFolder.ServerRelativeUrl;
    var url = electricalQuoteList.RootFolder.ServerRelativeUrl;
    var url2 = tenderSummarList.RootFolder.ServerRelativeUrl;
    var urlA = estimatingList.RootFolder.ServerRelativeUrl;
    var urlB = tenderSheduleList.RootFolder.ServerRelativeUrl;
    var urlC = tenderPricingList.RootFolder.ServerRelativeUrl;
    var foldername1 = string.Empty;
    var foldername = string.Empty;
    var foldername2 = string.Empty;
    var foldernameA = string.Empty;
    var foldernameB = string.Empty;
    var foldernameC = string.Empty;
    var folder1 = web.Folders[url1 + "/" + foldername1];
    var folder = web.Folders[url + "/" + foldername];
    var folder2 = web.Folders[url2 + "/" + foldername2];
    var folderA = web.Folders[urlA + "/" + foldernameA];
    var folderB = web.Folders[urlB + "/" + foldernameB];
    var folderC = web.Folders[urlC + "/" + foldernameC];
    if (!folder1.Exists && !folder.Exists && !folder2.Exists && !folderA.Exists && !folderB.Exists && !folderC.Exists)
    var folders1 = web.GetFolder(url1).SubFolders;
    var folders = web.GetFolder(url).SubFolders;
    var folders2 = web.GetFolder(url2).SubFolders;
    var foldersA = web.GetFolder(urlA).SubFolders;
    var foldersB = web.GetFolder(urlB).SubFolders;
    var foldersC = web.GetFolder(urlC).SubFolders;
    folders1.Add(foldername1);
    folders.Add(foldername);
    folders2.Add(foldername2);
    foldersA.Add(foldernameA);
    foldersB.Add(foldernameB);
    foldersC.Add(foldernameC);
    var file1 = web.GetFile(web.Site.Url + TemplateUrl1);
    var file = web.GetFile(web.Site.Url + TemplateUrl);
    var file2 = web.GetFile(web.Site.Url + TemplateUrl2);
    var fileA = web.GetFile(web.Site.Url + RfiTemplateUrl);
    var fileB = web.GetFile(web.Site.Url + DrawingTemplateUrl);
    var fileC = web.GetFile(web.Site.Url + TenderReturnTemplateUrl);
    if (file1 != null && file != null && file2 != null && fileA != null && fileB != null && fileC != null)
    var fileName = string.Format("{0}/{1}{2}", folder1.ServerRelativeUrl, this.projectName, ".xlsm");
    LogIssue(web, null, "Web Id : " + web.ID, "Copying file 1 {0} to {1}...", file1.Name, fileName);
    var byteArray1 = file1.OpenBinary();
    var uploadedFile1 = folder1.Files.Add(fileName, byteArray1, true);
    LogIssue(web, null, "Web Id : " + web.ID, "File 1 Uploaded with new ID of {0}", uploadedFile1.Item.ID);
    this.EventFiringEnabled = false;
    var listitem1 = uploadedFile1.Item;
    listitem1["Name"] = this.projectName;
    listitem1["EnquiryNo"] = finalNum;
    listitem1["Project_Name"] = this.projectName;
    listitem1["Tender_Received"] = this.tenderReceived;
    listitem1["Tender_Return"] = this.tenderReturn;
    listitem1["Quotation_Analysis_Mech_Url"] = "https://groupportal.sharepoint.com/sites/EnginSouth/Quotation%20Analysis%20Mechanical/Forms/DispForm.aspx?ID=" + listitem1.ID;
    listitem1.SystemUpdate(false);
    this.EventFiringEnabled = true;
    LogIssue(web, null, "Web Id : " + web.ID, "Copied file 1.");
    fileName = string.Format("{0}/{1}{2}", folder.ServerRelativeUrl, this.projectName, ".xlsm");
    LogIssue(web, null, "Web Id : " + web.ID, "Copying file 2 {0} to {1}...", file.Name, fileName);
    var byteArray = file.OpenBinary();
    var uploadedFile = folder.Files.Add(fileName, byteArray, true);
    LogIssue(web, null, "Web Id : " + web.ID, "File 2 Uploaded with new ID of {0}", uploadedFile.Item.ID);
    this.EventFiringEnabled = false;
    var listitem = uploadedFile.Item;
    listitem["Name"] = this.projectName;
    listitem["EnquiryNo"] = finalNum;
    listitem["Project_Name"] = this.projectName;
    listitem["Tender_Received"] = this.tenderReceived;
    listitem["Tender_Return"] = this.tenderReturn;
    listitem["Quotation_Analysis_Elec_Url"] = "https://groupportal.sharepoint.com/sites/EnginSouth/Quotation%20Analysis%20Electrical/Forms/DispForm.aspx?ID=" + listitem.ID;
    listitem.SystemUpdate(false);
    this.EventFiringEnabled = true;
    LogIssue(web, null, "Web Id : " + web.ID, "Copied file 2.");
    fileName = string.Format("{0}/{1}{2}", folderA.ServerRelativeUrl, this.projectName, ".docx");
    LogIssue(web, null, "Web Id : " + web.ID, "Copying file 3 {0} to {1}...", fileA.Name, fileName);
    var byteArrayA = fileA.OpenBinary();
    var uploadedFileA = folderA.Files.Add(fileName, byteArrayA, true);
    LogIssue(web, null, "Web Id : " + web.ID, "File 3 Uploaded with new ID of {0}", uploadedFileA.Item.ID);
    this.EventFiringEnabled = false;
    var listitemA = uploadedFileA.Item;
    listitemA["Name"] = this.projectName;
    listitemA["EnquiryNo"] = finalNum;
    listitemA["Project_Name"] = this.projectName;
    listitemA["Date"] = this.docDate;
    listitemA["Description"] = this.description;
    listitemA["ProjectNo"] = this.projectNumber;
    listitemA["RFIUrl"] = "https://groupportal.sharepoint.com/sites/EnginSouth/EstimatingRFI/Forms/DispForm.aspx?ID=" + listitemA.ID;
    listitemA.SystemUpdate(false);
    this.EventFiringEnabled = true;
    LogIssue(web, null, "Web Id : " + web.ID, "Copied file 3.");
    fileName = string.Format("{0}/{1}{2}", folderB.ServerRelativeUrl, this.projectName, ".docx");
    LogIssue(web, null, "Web Id : " + web.ID, "Copying file 4 {0} to {1}...", fileB.Name, fileName);
    var byteArrayB = fileB.OpenBinary();
    var uploadedFileB = folderB.Files.Add(fileName, byteArrayB, true);
    LogIssue(web, null, "Web Id : " + web.ID, "File 4 Uploaded with new ID of {0}", uploadedFileB.Item.ID);
    this.EventFiringEnabled = false;
    var listitemB = uploadedFileB.Item;
    listitemB["Name"] = this.projectName;
    listitemB["EnquiryNo"] = finalNum;
    listitemB["Project_Name"] = this.projectName;
    listitemB["Date"] = this.docDate;
    listitemB["Description"] = this.description;
    listitemB["ProjectNo"] = this.projectNumber;
    listitemB["DrawingURL"] = "https://groupportal.sharepoint.com/sites/EnginSouth/Tender%20and%20Drawing%20Schedule/Forms/DispForm.aspx?ID=" + listitemB.ID;
    listitemB.SystemUpdate(false);
    this.EventFiringEnabled = true;
    LogIssue(web, null, "Web Id : " + web.ID, "Copied file 4.");
    fileName = string.Format("{0}/{1}{2}", folderC.ServerRelativeUrl, this.projectName, ".xlsm");
    LogIssue(web, null, "Web Id : " + web.ID, "Copying file 5 {0} to {1}...", fileC.Name, fileName);
    var byteArrayC = fileC.OpenBinary();
    var uploadedFileC = folderC.Files.Add(fileName, byteArrayC, true);
    LogIssue(web, null, "Web Id : " + web.ID, "File 5 Uploaded with new ID of {0}", uploadedFileC.Item.ID);
    this.EventFiringEnabled = false;
    var listitemC = uploadedFileC.Item;
    listitemC["Name"] = this.projectName;
    listitemC["EnquiryNo"] = finalNum;
    listitemC["Project_Name"] = this.projectName;
    listitemC["Date"] = this.docDate;
    listitemC["Description"] = this.description;
    listitemC["ProjectNo"] = this.projectNumber;
    listitemC["PricingURL"] = "https://groupportal.sharepoint.com/sites/EnginSouth/Est_Tender_Pricing_Document/Forms/DispForm.aspx?ID=" + listitemC.ID;
    listitemC.SystemUpdate(false);
    this.EventFiringEnabled = true;
    LogIssue(web, null, "Web Id : " + web.ID, "Copied file 5.");
    fileName = string.Format("{0}/{1}{2}", folder2.ServerRelativeUrl, this.projectName, ".xlsm");
    LogIssue(web, null, "Web Id : " + web.ID, "Copying file 5 {0} to {1}...", file2.Name, fileName);
    var byteArray2 = file2.OpenBinary();
    var uploadedFile2 = folder2.Files.Add(fileName, byteArray2, true);
    LogIssue(web, null, "Web Id : " + web.ID, "File 6 Uploaded with new ID of {0}", uploadedFile2.Item.ID);
    this.EventFiringEnabled = false;
    var listitem2 = uploadedFile2.Item;
    listitem2["Name"] = this.projectName;
    listitem2["EnquiryNo"] = finalNum;
    listitem2["Project_Name"] = this.projectName;
    listitem2["Date"] = this.docDate;
    listitem2["Team"] = this.team;
    listitem2["Estimator_Electrical"] = this.electrical;
    listitem2["Estimator_Mechanical"] = this.mechanical;
    listitem2["Status"] = this.status;
    listitem2["Tender_Received"] = this.tenderReceived;
    listitem2["Tender_Return"] = this.tenderReturn;
    listitem2["Sector"] = this.sector;
    listitem2["Design_Build"] = this.designBuild;
    listitem2["Build_Type"] = this.buildType;
    listitem2["Service_Prog_Start"] = this.serviceProgramStart;
    listitem2["Service_Prog_Completion"] = this.serviceProgramCompletion;
    listitem2["Client_1"] = this.client1;
    listitem2["Client_2"] = this.client2;
    listitem2["Client_3"] = this.client3;
    listitem2["Client_4"] = this.client4;
    listitem2["Consultant"] = this.consultant;
    listitem2["Pre-construction_Prog_Start"] = this.preConstructionProgramStart;
    listitem2["Pre-construction_Prog_End"] = this.preConstructionProgramEnd;
    listitem2["Tender_Summary_Url"] = "https://groupportal.sharepoint.com/sites/EnginSouth/TenderSummaryLib/Forms/DispForm.aspx?ID=" + listitem2.ID;
    listitem2.SystemUpdate(false);
    this.EventFiringEnabled = true;
    LogIssue(web, null, "Web Id : " + web.ID, "Copied file 6.");
    /// <summary>
    /// Creates the folders.
    /// </summary>
    /// <param name="web">The web.</param>
    private void CreateFolders(SPWeb web)
    var projectListId = web.Lists.Add(this.projectName.Replace(' ', '_'), string.Empty, SPListTemplateType.DocumentLibrary);
    var projectList = web.Lists[projectListId];
    projectList.OnQuickLaunch = true; // The document library will appear in Quick Launch bar.
    CreateFolder(projectList, "1.Tender Documents");
    CreateFolder(projectList, "2. Electrical");
    CreateFolder(projectList, "3. Mechanical");
    CreateFolder(projectList, "4. Correspondance");
    CreateFolder(projectList, "5. Settlement Meeting Docs");
    CreateFolder(projectList, "6. Tender Return Docs");
    CreateFolder(projectList, "7. Tender Handover");
    projectList.Update();
    /// <summary>
    /// Initializes the specified list item.
    /// </summary>
    /// <param name="listItem">The list item.</param>
    /// <param name="finalNum">The final number.</param>
    private void Initialize(SPListItem listItem, string finalNum)
    var contextId = string.Format("List:{0}, Id:{1}", listItem.ParentList.Title, listItem.ID);
    this.noBid = AssignField(listItem, "Bid", contextId);
    this.projectName = AssignField(listItem, "Project_Name", contextId);
    var teamlookup = AssignField(listItem, "Team", contextId);
    var lookupParts = teamlookup.Split(new[] { ";#" }, StringSplitOptions.None);
    this.team = lookupParts[1];
    this.description = AssignField(listItem, "Description", contextId);
    this.status = AssignField(listItem, "enquiry_status", contextId);
    this.electrical = AssignUserField(listItem, "electrical_proj_manager", contextId);
    this.mechanical = AssignUserField(listItem, "mechanical_proj_manager", contextId);
    this.docDate = AssignDateField(listItem, "Date", contextId);
    this.tenderReceived = AssignDateField(listItem, "Tender_Received", contextId);
    this.tenderReturn = AssignDateField(listItem, "Tender_Return", contextId);
    this.preConstructionProgramStart = AssignDateField(listItem, "Pre-construction_Prog_Start", contextId);
    this.preConstructionProgramEnd = AssignDateField(listItem, "Pre-construction_Prog_End", contextId);
    this.sector = AssignField(listItem, "Sector", contextId);
    this.designBuild = AssignField(listItem, "Design_Build", contextId);
    this.buildType = AssignField(listItem, "Build_Type", contextId);
    this.serviceProgramStart = AssignDateField(listItem, "Service_Prog_Start", contextId);
    this.serviceProgramCompletion = AssignDateField(listItem, "Service_Prog_Completion", contextId);
    this.client1 = AssignField(listItem, "Client_1", contextId);
    this.client2 = AssignField(listItem, "Client_2", contextId);
    this.client3 = AssignField(listItem, "Client_3", contextId);
    this.client4 = AssignField(listItem, "Client_4", contextId);
    this.consultant = AssignField(listItem, "Consultant", contextId);
    if (this.status == "Won")
    this.projectNumber = string.Format("15-{0}-{1}", this.team, new Random().Next(0, 9999).ToString("D4"));
    if (this.status == "Active" || this.status == "Closed")
    this.projectNumber = "No Project No";
    listItem["ProjectNo"] = this.projectNumber;
    listItem["EnquiryNo"] = finalNum;
    listItem.Web.AllowUnsafeUpdates = true;
    listItem.SystemUpdate(false);

    Hi,
    In this forum we mainly discuss questions and feedbacks about Office client products, as your question is about SharePoint 2013, I suggest you post this thread in SharePoint forum:
    https://social.technet.microsoft.com/Forums/office/en-US/home?category=sharepoint
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    Regards,
    Melon Chen
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs. Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • SharePoint online 2013 event receiver error

    I am currently working on a SharePoint online project. My code generates 6 documents in 6 different document libraries along with other metadata. When I save data to a List, the event receiver fires and creates all the 6 documents. But sometimes it stops creating
    the 6 documents and left with 1 or 2 documents. Sometimes documents has been created but without any metadata.
    The same code is working fine in my on-premises environment, but it sometimes breaks in the Office 365 environment. I also created a log list to track the issue as we cannot debug in Office 365. In the log list I found a error message saying "Thread was
    being aborted." Below is my code. please help it is happening only in Office 365 environment.
    namespace ExcelGen.ExcelGenReceiver
    using System;
    using Microsoft.SharePoint;
    /// <summary>
    /// List Item Events
    /// </summary>
    public class ExcelGenReceiver : SPItemEventReceiver
    /// <summary>
    /// The template URL
    /// </summary>
    private const string TemplateUrl = "/Quotation Analysis Electrical/Forms/Quotation Analysis Sheet ELEC_Blank.xlsm";
    /// <summary>
    /// The template url1
    /// </summary>
    private const string TemplateUrl1 = "/Quotation Analysis Mechanical/Forms/Quotation Analysis Sheet MECH_Blank.xlsm";
    /// <summary>
    /// The template url2
    /// </summary>
    private const string TemplateUrl2 = "/TenderSummaryLib/Forms/TenderSummaryBlankMaster1.xlsm";
    /// <summary>
    /// The RFI template URL
    /// </summary>
    private const string RfiTemplateUrl = "/EstimatingRFI/Forms/RFI Schedule MASTER.docx";
    /// <summary>
    /// The drawing template URL
    /// </summary>
    private const string DrawingTemplateUrl = "/Tender and Drawing Schedule/Forms/Tender Document Drawing Schedule.docx";
    /// <summary>
    /// The tender return template URL
    /// </summary>
    private const string TenderReturnTemplateUrl = "/Est_Tender_Pricing_Document/Forms/Tender Pricing Document blank.xlsm";
    /// <summary>
    /// The project number
    /// </summary>
    private string projectNumber = string.Empty;
    /// <summary>
    /// The project name
    /// </summary>
    private string projectName = string.Empty;
    /// <summary>
    /// The no bid
    /// </summary>
    private string noBid;
    /// <summary>
    /// The team
    /// </summary>
    private string team;
    /// <summary>
    /// The description
    /// </summary>
    private string description;
    /// <summary>
    /// The status
    /// </summary>
    private string status;
    /// <summary>
    /// The electrical
    /// </summary>
    private SPUser electrical;
    /// <summary>
    /// The mechanical
    /// </summary>
    private SPUser mechanical;
    /// <summary>
    /// The document date
    /// </summary>
    private DateTime? docDate;
    /// <summary>
    /// The tender received
    /// </summary>
    private DateTime? tenderReceived;
    /// <summary>
    /// The tender return
    /// </summary>
    private DateTime? tenderReturn;
    /// <summary>
    /// The pre construction program start date
    /// </summary>
    private DateTime? preConstructionProgramStart;
    /// <summary>
    /// The pre construction program end date
    /// </summary>
    private DateTime? preConstructionProgramEnd;
    /// <summary>
    /// The sector
    /// </summary>
    private string sector;
    /// <summary>
    /// The design build
    /// </summary>
    private string designBuild;
    /// <summary>
    /// The build type
    /// </summary>
    private string buildType;
    /// <summary>
    /// The service program start date
    /// </summary>
    private DateTime? serviceProgramStart;
    /// <summary>
    /// The service program completion date
    /// </summary>
    private DateTime? serviceProgramCompletion;
    /// <summary>
    /// The client1
    /// </summary>
    private string client1;
    /// <summary>
    /// The client2
    /// </summary>
    private string client2;
    /// <summary>
    /// The client3
    /// </summary>
    private string client3;
    /// <summary>
    /// The client4
    /// </summary>
    private string client4;
    /// <summary>
    /// The consultant
    /// </summary>
    private string consultant;
    /// <summary>
    /// An item is being added.
    /// </summary>
    /// <param name="properties">The Item Event properties</param>
    public override void ItemAdded(SPItemEventProperties properties)
    //this.EventFiringEnabled = false;
    var web = properties.Web;
    var listItem = properties.ListItem;
    try
    LogIssue(web, null, "Item Added", "List Item Id {0}", listItem.ID);
    if (!this.AttemptCopyProcess(listItem))
    LogIssue(web, null, "List Id : " + listItem.ID, "AttemptCopyProcess failed.");
    catch (Exception ex)
    LogIssue(web, ex, "List Id : " + listItem.ID, "AttemptCopyProcess failed.");
    finally
    //this.EventFiringEnabled = true;
    LogIssue(web, null, "List Id : " + listItem.ID, "Event Receiver completed sucessfully.");
    /// <summary>
    /// Logs any issues found
    /// </summary>
    /// <param name="webContext">The web context.</param>
    /// <param name="exception">The exception, if null not exception details are written</param>
    /// <param name="contextId">The context identifier, a unique identifier that allows us to know where the call originated, i.e. a List and ListItem Id, or a Page Url</param>
    /// <param name="comment">The comment.</param>
    /// <param name="args">The arguments.</param>
    private static void LogIssue(SPWeb webContext, Exception exception, string contextId, string comment, params object[] args)
    //// if (webContext.AllProperties.ContainsKey("EnableLogging"))
    var list = webContext.Lists.TryGetList("ErrorIssues");
    if (list != null)
    var item = list.AddItem();
    item["Title"] = contextId;
    if (exception != null)
    item["Message"] = exception.Message;
    item["InnerException"] = exception.InnerException ?? (object)string.Empty;
    item["StackTrace"] = exception.StackTrace;
    if (!string.IsNullOrEmpty(comment))
    item["Comment"] = string.Format(comment, args);
    item.Update();
    /// <summary>
    /// Assigns the field.
    /// </summary>
    /// <param name="listItem">The list item.</param>
    /// <param name="fieldName">Name of the field.</param>
    /// <param name="contextId">The context identifier.</param>
    /// <returns>The fields string value if present, otherwise string.empty.</returns>
    private static string AssignField(SPListItem listItem, string fieldName, string contextId)
    var fieldValue = string.Empty;
    if (listItem.Fields.ContainsField(fieldName) && listItem[fieldName] != null)
    fieldValue = listItem[fieldName].ToString();
    else
    LogIssue(listItem.Web, null, contextId, string.Format("Field not available : {0}", fieldName));
    return fieldValue;
    /// <summary>
    /// Assigns the field as a DateTime
    /// </summary>
    /// <param name="listItem">The list item.</param>
    /// <param name="fieldName">Name of the field.</param>
    /// <param name="contextId">The context identifier.</param>
    /// <returns>Returns the date if found, otherwise returns DateTime.MinValue</returns>
    private static DateTime? AssignDateField(SPListItem listItem, string fieldName, string contextId)
    DateTime? fieldValue = null;
    if (listItem.Fields.ContainsField(fieldName) && listItem[fieldName] != null)
    fieldValue = Convert.ToDateTime(listItem[fieldName].ToString());
    else
    LogIssue(listItem.Web, null, contextId, string.Format("Field not available : {0}", fieldName));
    return fieldValue;
    /// <summary>
    /// Creates the folder.
    /// </summary>
    /// <param name="listdoc">The list.</param>
    /// <param name="folderName">Name of the folder.</param>
    private static void CreateFolder(SPList listdoc, string folderName)
    LogIssue(listdoc.ParentWeb, null, "List Id : " + listdoc.ID, "Creating folder {0} in {1}", folderName, listdoc.RootFolder.ServerRelativeUrl);
    // Updated by Indusnet
    SPListItem folder1 = listdoc.Items.Add(listdoc.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder);
    folder1["Name"] = folderName;
    folder1.Update();
    listdoc.Update();
    // End Updated
    /// <summary>
    /// Assigns the user field.
    /// </summary>
    /// <param name="listItem">The list item.</param>
    /// <param name="fieldName">Name of the field.</param>
    /// <param name="contextId">The context identifier.</param>
    /// <returns>Returns the user if found, otherwise null.</returns>
    private static SPUser AssignUserField(SPListItem listItem, string fieldName, string contextId)
    SPUser user = null;
    if (listItem.Fields.ContainsField(fieldName) && listItem[fieldName] != null)
    var userField = (SPFieldUser)listItem.Fields.GetField(fieldName);
    var fieldValue = (SPFieldUserValue)userField.GetFieldValue(listItem["electrical_proj_manager"].ToString());
    user = fieldValue.User;
    else
    LogIssue(listItem.Web, null, contextId, string.Format("Field not available : {0}", fieldName));
    return user;
    /// <summary>
    /// Attempts the copy process.
    /// </summary>
    /// <param name="listItem">The list item.</param>
    /// <returns>True if it successfully processed, false otherwise.</returns>
    private bool AttemptCopyProcess(SPListItem listItem)
    if (listItem.ParentList.Title != "Enquiry_Template")
    LogIssue(listItem.Web, null, "List Id : " + listItem.ID, "ListItem titles is not Enquiry_Template, aborting.");
    return false;
    var finalNum = "15-" + new Random().Next(0, 9999).ToString("D4");
    this.Initialize(listItem, finalNum);
    if (this.noBid != "Yes")
    LogIssue(listItem.Web, null, "List Id : " + listItem.ID, "The noBid field does not equal Yes, aborting.");
    return false;
    this.CopyFiles(listItem.Web, finalNum);
    this.CreateFolders(listItem.Web);
    return true;
    /// <summary>
    /// Copies the files.
    /// </summary>
    /// <param name="web">The web.</param>
    /// <param name="finalNum">The final number.</param>
    private void CopyFiles(SPWeb web, string finalNum)
    LogIssue(web, null, "Web Id : " + web.ID, "Setting the copying of files ...");
    var mechanicalQuoteList = web.Lists["Quotation Analysis Mechanical"];
    var electricalQuoteList = web.Lists["Quotation Analysis Electrical"];
    var tenderSummarList = web.Lists["TenderSummaryLib"];
    var estimatingList = web.Lists["EstimatingRFI"];
    var tenderSheduleList = web.Lists["Tender and Drawing Schedule"];
    var tenderPricingList = web.Lists["Est_Tender_Pricing_Document"];
    var url1 = mechanicalQuoteList.RootFolder.ServerRelativeUrl;
    var url = electricalQuoteList.RootFolder.ServerRelativeUrl;
    var url2 = tenderSummarList.RootFolder.ServerRelativeUrl;
    var urlA = estimatingList.RootFolder.ServerRelativeUrl;
    var urlB = tenderSheduleList.RootFolder.ServerRelativeUrl;
    var urlC = tenderPricingList.RootFolder.ServerRelativeUrl;
    var foldername1 = string.Empty;
    var foldername = string.Empty;
    var foldername2 = string.Empty;
    var foldernameA = string.Empty;
    var foldernameB = string.Empty;
    var foldernameC = string.Empty;
    var folder1 = web.Folders[url1 + "/" + foldername1];
    var folder = web.Folders[url + "/" + foldername];
    var folder2 = web.Folders[url2 + "/" + foldername2];
    var folderA = web.Folders[urlA + "/" + foldernameA];
    var folderB = web.Folders[urlB + "/" + foldernameB];
    var folderC = web.Folders[urlC + "/" + foldernameC];
    if (!folder1.Exists && !folder.Exists && !folder2.Exists && !folderA.Exists && !folderB.Exists && !folderC.Exists)
    var folders1 = web.GetFolder(url1).SubFolders;
    var folders = web.GetFolder(url).SubFolders;
    var folders2 = web.GetFolder(url2).SubFolders;
    var foldersA = web.GetFolder(urlA).SubFolders;
    var foldersB = web.GetFolder(urlB).SubFolders;
    var foldersC = web.GetFolder(urlC).SubFolders;
    folders1.Add(foldername1);
    folders.Add(foldername);
    folders2.Add(foldername2);
    foldersA.Add(foldernameA);
    foldersB.Add(foldernameB);
    foldersC.Add(foldernameC);
    var file1 = web.GetFile(web.Site.Url + TemplateUrl1);
    var file = web.GetFile(web.Site.Url + TemplateUrl);
    var file2 = web.GetFile(web.Site.Url + TemplateUrl2);
    var fileA = web.GetFile(web.Site.Url + RfiTemplateUrl);
    var fileB = web.GetFile(web.Site.Url + DrawingTemplateUrl);
    var fileC = web.GetFile(web.Site.Url + TenderReturnTemplateUrl);
    if (file1 != null && file != null && file2 != null && fileA != null && fileB != null && fileC != null)
    var fileName = string.Format("{0}/{1}{2}", folder1.ServerRelativeUrl, this.projectName, ".xlsm");
    LogIssue(web, null, "Web Id : " + web.ID, "Copying file 1 {0} to {1}...", file1.Name, fileName);
    var byteArray1 = file1.OpenBinary();
    var uploadedFile1 = folder1.Files.Add(fileName, byteArray1, true);
    LogIssue(web, null, "Web Id : " + web.ID, "File 1 Uploaded with new ID of {0}", uploadedFile1.Item.ID);
    this.EventFiringEnabled = false;
    var listitem1 = uploadedFile1.Item;
    listitem1["Name"] = this.projectName;
    listitem1["EnquiryNo"] = finalNum;
    listitem1["Project_Name"] = this.projectName;
    listitem1["Tender_Received"] = this.tenderReceived;
    listitem1["Tender_Return"] = this.tenderReturn;
    listitem1["Quotation_Analysis_Mech_Url"] = "https://my site url/Quotation%20Analysis%20Mechanical/Forms/DispForm.aspx?ID=" + listitem1.ID;
    listitem1.SystemUpdate(false);
    this.EventFiringEnabled = true;
    LogIssue(web, null, "Web Id : " + web.ID, "Copied file 1.");
    fileName = string.Format("{0}/{1}{2}", folder.ServerRelativeUrl, this.projectName, ".xlsm");
    LogIssue(web, null, "Web Id : " + web.ID, "Copying file 2 {0} to {1}...", file.Name, fileName);
    var byteArray = file.OpenBinary();
    var uploadedFile = folder.Files.Add(fileName, byteArray, true);
    LogIssue(web, null, "Web Id : " + web.ID, "File 2 Uploaded with new ID of {0}", uploadedFile.Item.ID);
    this.EventFiringEnabled = false;
    var listitem = uploadedFile.Item;
    listitem["Name"] = this.projectName;
    listitem["EnquiryNo"] = finalNum;
    listitem["Project_Name"] = this.projectName;
    listitem["Tender_Received"] = this.tenderReceived;
    listitem["Tender_Return"] = this.tenderReturn;
    listitem["Quotation_Analysis_Elec_Url"] = "https://my site url/Quotation%20Analysis%20Electrical/Forms/DispForm.aspx?ID=" + listitem.ID;
    listitem.SystemUpdate(false);
    this.EventFiringEnabled = true;
    LogIssue(web, null, "Web Id : " + web.ID, "Copied file 2.");
    fileName = string.Format("{0}/{1}{2}", folderA.ServerRelativeUrl, this.projectName, ".docx");
    LogIssue(web, null, "Web Id : " + web.ID, "Copying file 3 {0} to {1}...", fileA.Name, fileName);
    var byteArrayA = fileA.OpenBinary();
    var uploadedFileA = folderA.Files.Add(fileName, byteArrayA, true);
    LogIssue(web, null, "Web Id : " + web.ID, "File 3 Uploaded with new ID of {0}", uploadedFileA.Item.ID);
    this.EventFiringEnabled = false;
    var listitemA = uploadedFileA.Item;
    listitemA["Name"] = this.projectName;
    listitemA["EnquiryNo"] = finalNum;
    listitemA["Project_Name"] = this.projectName;
    listitemA["Date"] = this.docDate;
    listitemA["Description"] = this.description;
    listitemA["ProjectNo"] = this.projectNumber;
    listitemA["RFIUrl"] = "https://my site url/EstimatingRFI/Forms/DispForm.aspx?ID=" + listitemA.ID;
    listitemA.SystemUpdate(false);
    this.EventFiringEnabled = true;
    LogIssue(web, null, "Web Id : " + web.ID, "Copied file 3.");
    fileName = string.Format("{0}/{1}{2}", folderB.ServerRelativeUrl, this.projectName, ".docx");
    LogIssue(web, null, "Web Id : " + web.ID, "Copying file 4 {0} to {1}...", fileB.Name, fileName);
    var byteArrayB = fileB.OpenBinary();
    var uploadedFileB = folderB.Files.Add(fileName, byteArrayB, true);
    LogIssue(web, null, "Web Id : " + web.ID, "File 4 Uploaded with new ID of {0}", uploadedFileB.Item.ID);
    this.EventFiringEnabled = false;
    var listitemB = uploadedFileB.Item;
    listitemB["Name"] = this.projectName;
    listitemB["EnquiryNo"] = finalNum;
    listitemB["Project_Name"] = this.projectName;
    listitemB["Date"] = this.docDate;
    listitemB["Description"] = this.description;
    listitemB["ProjectNo"] = this.projectNumber;
    listitemB["DrawingURL"] = "https://my site url/Tender%20and%20Drawing%20Schedule/Forms/DispForm.aspx?ID=" + listitemB.ID;
    listitemB.SystemUpdate(false);
    this.EventFiringEnabled = true;
    LogIssue(web, null, "Web Id : " + web.ID, "Copied file 4.");
    fileName = string.Format("{0}/{1}{2}", folderC.ServerRelativeUrl, this.projectName, ".xlsm");
    LogIssue(web, null, "Web Id : " + web.ID, "Copying file 5 {0} to {1}...", fileC.Name, fileName);
    var byteArrayC = fileC.OpenBinary();
    var uploadedFileC = folderC.Files.Add(fileName, byteArrayC, true);
    LogIssue(web, null, "Web Id : " + web.ID, "File 5 Uploaded with new ID of {0}", uploadedFileC.Item.ID);
    this.EventFiringEnabled = false;
    var listitemC = uploadedFileC.Item;
    listitemC["Name"] = this.projectName;
    listitemC["EnquiryNo"] = finalNum;
    listitemC["Project_Name"] = this.projectName;
    listitemC["Date"] = this.docDate;
    listitemC["Description"] = this.description;
    listitemC["ProjectNo"] = this.projectNumber;
    listitemC["PricingURL"] = "https://my site url/Est_Tender_Pricing_Document/Forms/DispForm.aspx?ID=" + listitemC.ID;
    listitemC.SystemUpdate(false);
    this.EventFiringEnabled = true;
    LogIssue(web, null, "Web Id : " + web.ID, "Copied file 5.");
    fileName = string.Format("{0}/{1}{2}", folder2.ServerRelativeUrl, this.projectName, ".xlsm");
    LogIssue(web, null, "Web Id : " + web.ID, "Copying file 5 {0} to {1}...", file2.Name, fileName);
    var byteArray2 = file2.OpenBinary();
    var uploadedFile2 = folder2.Files.Add(fileName, byteArray2, true);
    LogIssue(web, null, "Web Id : " + web.ID, "File 6 Uploaded with new ID of {0}", uploadedFile2.Item.ID);
    this.EventFiringEnabled = false;
    var listitem2 = uploadedFile2.Item;
    listitem2["Name"] = this.projectName;
    listitem2["EnquiryNo"] = finalNum;
    listitem2["Project_Name"] = this.projectName;
    listitem2["Date"] = this.docDate;
    listitem2["Team"] = this.team;
    listitem2["Estimator_Electrical"] = this.electrical;
    listitem2["Estimator_Mechanical"] = this.mechanical;
    listitem2["Status"] = this.status;
    listitem2["Tender_Received"] = this.tenderReceived;
    listitem2["Tender_Return"] = this.tenderReturn;
    listitem2["Sector"] = this.sector;
    listitem2["Design_Build"] = this.designBuild;
    listitem2["Build_Type"] = this.buildType;
    listitem2["Service_Prog_Start"] = this.serviceProgramStart;
    listitem2["Service_Prog_Completion"] = this.serviceProgramCompletion;
    listitem2["Client_1"] = this.client1;
    listitem2["Client_2"] = this.client2;
    listitem2["Client_3"] = this.client3;
    listitem2["Client_4"] = this.client4;
    listitem2["Consultant"] = this.consultant;
    listitem2["Pre-construction_Prog_Start"] = this.preConstructionProgramStart;
    listitem2["Pre-construction_Prog_End"] = this.preConstructionProgramEnd;
    listitem2["Tender_Summary_Url"] = "https://my site url/TenderSummaryLib/Forms/DispForm.aspx?ID=" + listitem2.ID;
    listitem2.SystemUpdate(false);
    this.EventFiringEnabled = true;
    LogIssue(web, null, "Web Id : " + web.ID, "Copied file 6.");
    /// <summary>
    /// Creates the folders.
    /// </summary>
    /// <param name="web">The web.</param>
    private void CreateFolders(SPWeb web)
    var projectListId = web.Lists.Add(this.projectName.Replace(' ', '_'), string.Empty, SPListTemplateType.DocumentLibrary);
    var projectList = web.Lists[projectListId];
    projectList.OnQuickLaunch = true; // The document library will appear in Quick Launch bar.
    CreateFolder(projectList, "1.Tender Documents");
    CreateFolder(projectList, "2. Electrical");
    CreateFolder(projectList, "3. Mechanical");
    CreateFolder(projectList, "4. Correspondance");
    CreateFolder(projectList, "5. Settlement Meeting Docs");
    CreateFolder(projectList, "6. Tender Return Docs");
    CreateFolder(projectList, "7. Tender Handover");
    projectList.Update();
    /// <summary>
    /// Initializes the specified list item.
    /// </summary>
    /// <param name="listItem">The list item.</param>
    /// <param name="finalNum">The final number.</param>
    private void Initialize(SPListItem listItem, string finalNum)
    var contextId = string.Format("List:{0}, Id:{1}", listItem.ParentList.Title, listItem.ID);
    this.noBid = AssignField(listItem, "Bid", contextId);
    this.projectName = AssignField(listItem, "Project_Name", contextId);
    var teamlookup = AssignField(listItem, "Team", contextId);
    var lookupParts = teamlookup.Split(new[] { ";#" }, StringSplitOptions.None);
    this.team = lookupParts[1];
    this.description = AssignField(listItem, "Description", contextId);
    this.status = AssignField(listItem, "enquiry_status", contextId);
    this.electrical = AssignUserField(listItem, "electrical_proj_manager", contextId);
    this.mechanical = AssignUserField(listItem, "mechanical_proj_manager", contextId);
    this.docDate = AssignDateField(listItem, "Date", contextId);
    this.tenderReceived = AssignDateField(listItem, "Tender_Received", contextId);
    this.tenderReturn = AssignDateField(listItem, "Tender_Return", contextId);
    this.preConstructionProgramStart = AssignDateField(listItem, "Pre-construction_Prog_Start", contextId);
    this.preConstructionProgramEnd = AssignDateField(listItem, "Pre-construction_Prog_End", contextId);
    this.sector = AssignField(listItem, "Sector", contextId);
    this.designBuild = AssignField(listItem, "Design_Build", contextId);
    this.buildType = AssignField(listItem, "Build_Type", contextId);
    this.serviceProgramStart = AssignDateField(listItem, "Service_Prog_Start", contextId);
    this.serviceProgramCompletion = AssignDateField(listItem, "Service_Prog_Completion", contextId);
    this.client1 = AssignField(listItem, "Client_1", contextId);
    this.client2 = AssignField(listItem, "Client_2", contextId);
    this.client3 = AssignField(listItem, "Client_3", contextId);
    this.client4 = AssignField(listItem, "Client_4", contextId);
    this.consultant = AssignField(listItem, "Consultant", contextId);
    if (this.status == "Won")
    this.projectNumber = string.Format("15-{0}-{1}", this.team, new Random().Next(0, 9999).ToString("D4"));
    if (this.status == "Active" || this.status == "Closed")
    this.projectNumber = "No Project No";
    listItem["ProjectNo"] = this.projectNumber;
    listItem["EnquiryNo"] = finalNum;
    listItem.Web.AllowUnsafeUpdates = true;
    listItem.SystemUpdate(false);

    Hi,
    In this forum we mainly discuss questions and feedbacks about Office client products, as your question is about SharePoint 2013, I suggest you post this thread in SharePoint forum:
    https://social.technet.microsoft.com/Forums/office/en-US/home?category=sharepoint
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    Regards,
    Melon Chen
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs. Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Getting Error In Item Added Event In Event Receiver in SharePoint 2010

    Hi Guys,
    I have written Event Receiver in SharePoint 2010 On ItemAdded event of Document Library. Wants to increment a col value by reading maximum value first. I wrote below code but sometime it works correctly but some time I got below error: Document Set
    enabled on this document library and weh we added any document in any document set then this event occurred. I mentioned Code block and Error description both.
    Please see and suggest right solution.
    Code:
    public override void ItemAdded(SPItemEventProperties properties)
                    base.ItemAdded(properties);
                    SPListItem _currentItem = properties.ListItem;
                    string _QUERY = @"<Where><Eq><FieldRef Name='DocumentId'/><Value Type='Text'>21</Value></Eq></Where><OrderBy><FieldRef
    Name='RevisionReference' Ascending='False' /></OrderBy><ViewFields><FieldRef Name='RevisionReference' /></ViewFields><QueryOptions><Folder>DocumentLIBB/</Folder></QueryOptions>";
                    int maxID = 0;
                    string revisionreferencee = string.Empty;
                    using (SPWeb web = properties.OpenWeb())
                        SPList list = web.Lists["DocumentLIBB"];
                        SPQuery query = new SPQuery();
                        query.ViewAttributes = "Scope=\"Recursive\"";
                        query.Query = (_QUERY);
                        SPListItemCollection results = list.GetItems(query);
                     if (results.Count > 0)
                            SPListItem item = results[0];
                            revisionreferencee = item["RevisionReference"].ToString();
                            bool result = Int32.TryParse(revisionreferencee, out maxID);
                            _currentItem["RevisionReference"] = maxID + 1;
                            _currentItem["DocumentId"] = item["DocumentId"].ToString();
                    properties.ListItem.File.Update();
                    _currentItem.Update();
    Error Desc:
    <nativehr>0x81020015</nativehr><nativestack></nativestack>The file EKENg LIBB/QA_DOC_044/05-22 Emirates Engineering Occurrence_Error Investigation - MEDA Process - 27 AUG 2009-921.doc has been modified by SHAREPOINT\system
    on 27 Aug 2012 12:10:13 +0400.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: System.Runtime.InteropServices.COMException: <nativehr>0x81020015</nativehr><nativestack></nativestack>The file EKENg LIBB/QA_DOC_044/05-22 Emirates Engineering Occurrence_Error Investigation - MEDA
    Process - 27 AUG 2009-921.doc has been modified by SHAREPOINT\system on 27 Aug 2012 12:10:13 +0400.
    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

    Making the event synchronous (rather than the default) eliminates this error. If such a change suits your requirements you should consider it. You just have to tweak the elements.xml in your feature receiver project;
    http://blogs.msdn.com/b/unsharepoint/archive/2010/11/10/sharepoint-event-receivers-making-asynchronous-event-synchronous-to-avoid-save-conflict-error.aspx
    w: http://www.the-north.com/sharepoint | t: @JMcAllisterCH | c: http://www.b-i.com

  • Getting Error while deploying the autohosted event receiver in office 365 ( ErrorDetail: There was a problem registering the app principal.):

    Hi,
    I was successfully able to deploy my auto hosted event receiver in office 365 and it was working. I did some changes on code and try to deploy it again but now it through same error always wheneven i deploy it.
     CorrelationId: 2ef8a311-f1cf-4ee7-be1a-1125c5231e1c
    2>        ErrorDetail: There was a problem registering the app principal.
    2>        ErrorType: Configuration
    2>        ErrorTypeName: Configuration
    2>        ExceptionMessage: An error occurred while attempting to execute a principal management operation.  Please contact your administrator.
    2>        Source: RemoteWebSite
    2>        SourceName: Remote Web Site Deployment
    2>Error occurred in deployment step 'Install app for SharePoint': Failed to install app for SharePoint. Please see the output window for details.
    Please help me on this. Not sure what this error is indicating.
    Regards:
    Sanjay Joshi

    Hi All,
    I have tried same thing in different different environment.  Different environment mean different azure account and office 365 account. But still the issue persists.
    i feel some issue in my office network or in servers. Because couple of days back same thing was working in my private virtual machine in my private network instead of office.
    For me i observe a basic problem in this network.
    The pop up to provide trust to the app (that come with title "Grant permission to app") comes while i deploy the solution and gets close automatically without clicking trust.
    Might be this could be the reason for me ?. because closing of pop up is not providing authentication to my app.
    This happens in every server in my office network.
    Any suggestions on that. Thanks in advance.
    Regards:
    Sanjay Joshi

  • Error when editing form --using an event receiver

    Hi,
    I created an event receiver sandbox solution and deployed it to preprod.  My code doesn't work and everytime I edit an item it gives me this error. I don't receive an error when I create an item.
    Server encountered an internal error. For more information, turn off customErrors in the server's .config file.
    at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) at Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bPreserveItemUIVersion,
    Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin,
    Boolean bMigration, Boolean bPublish, String bstrFileName, ISP2DSafeArrayWriter pListDataValidationCallback, ISP2DSafeArrayWriter pRestrictInsertCallback, ISP2DSafeArrayWriter pUniqueFieldCallback) at Microsoft.SharePoint.SPListItem.AddOrUpdateItem(Boolean
    bAdd, Boolean bSystem, Boolean bPreserveItemVersion, Boolean bNoVersion, Boolean bMigration, Boolean bPublish, Boolean bCheckOut, Boolean bCheckin, Guid newGuidOnAdd, Int32& ulID, Object& objAttachmentNames, Object& objAttachmentContents, Boolean
    suppressAfterEvents, String filename, Boolean bPreserveItemUIVersion) at Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut,
    Boolean bCheckin, Boolean suppressAfterEvents, String filename, Boolean bPreserveItemUIVersion) at Microsoft.SharePoint.SPListItem.Update() at Microsoft.SharePoint.WebControls.SaveButton.SaveItem(SPContext itemContext, Boolean uploadMode, String checkInComment)
    at Microsoft.SharePoint.WebControls.SaveButton.OnBubbleEvent(Object source, EventArgs e) at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    private bool HasFieldChanged(SPItemEventProperties properties, string sInternalName)
    if (properties.ListItem[sInternalName] != null && properties.AfterProperties[properties.ListItem.Fields[sInternalName].StaticName] != null)
    //before properties is not equal than after properties
    return !properties.ListItem[sInternalName].ToString().Equals(properties.AfterProperties[properties.ListItem.Fields[sInternalName].StaticName].ToString(), StringComparison.OrdinalIgnoreCase);
    return false;
     public override void ItemUpdating(SPItemEventProperties properties)
     base.ItemUpdating(properties);
     try
     if (HasFieldChanged(properties, "WHQ") && !HasFieldChanged(properties, "Employee Type"))
     SPList oSPList = properties.Web.Lists["EPDEMails"];
     SPListItem oSPItem = oSPList.AddItem();
     SPListItem item = properties.ListItem;
     string sAfterWHQDepartment = properties.AfterProperties[properties.ListItem.Fields["WHQ Department"].StaticName].ToString();
     string sBeforeWHQDepartment = item[properties.ListItem.Fields["WHQ Department"].StaticName].ToString();
     string sEmails = string.Empty;           
     string sGroups = string.Format("{0},{1},Editors", sAfterWHQDepartment, sBeforeWHQDepartment);
     foreach (string group in sGroups.Split(','))
     foreach (SPUser thisuser in properties.Web.Groups[group].Users)
                                sEmails += thisuser.Email + ";";
                        oSPItem["Subject"] = "Employee Transfer to a different WHQ Department";
                        oSPItem["To"] = sEmails;
                        oSPItem["Body"] = string.Format("{0} {1} has been transferred to {2} from {3}. Please update EPD ASAP", item["First Name"],
    item["Last Name"], sAfterWHQDepartment, sBeforeWHQDepartment);
                        oSPItem.Update();
      if (HasFieldChanged(properties, "Region") && !HasFieldChanged(properties, "Employee Type"))
                    SPList oSPList = properties.Web.Lists["EPDEMails"];        
      SPListItem oSPItem = oSPList.AddItem();
      SPListItem item = properties.ListItem;
      string sAfterRegion = properties.AfterProperties[properties.ListItem.Fields["Region"].StaticName].ToString();
      string sBeforeRegion = item[properties.ListItem.Fields["Region"].StaticName].ToString();
      string sEmails = string.Empty;
      string sGroups = string.Format("{0},{1},Editors", sAfterRegion, sBeforeRegion);
      foreach (string group in sGroups.Split(','))
      foreach (SPUser thisuser in properties.Web.Groups[group].Users)
                           sEmails += thisuser.Email + ";";
                        oSPItem["Subject"] = "Employee Transfer to a different Region";
                        oSPItem["To"] = sEmails;
                        oSPItem["Body"] = string.Format("{0} {1} has been transferred to {2} from {3}. Please update EPD ASAP", item["First Name"],
    item["Las tName"], sAfterRegion, sBeforeRegion);
                        oSPItem.Update();
     if (HasFieldChanged(properties, "Employee Type"))
     SPList oSPList = properties.Web.Lists["EPDEMails"];
     SPListItem oSPItem = oSPList.AddItem();
     SPListItem item = properties.ListItem;
     string sChangedEmployeeType = properties.AfterProperties[properties.ListItem.Fields["Employee Type"].StaticName].ToString();
     if (sChangedEmployeeType == "Region")
    string sAfterRegion = properties.AfterProperties[properties.ListItem.Fields["Region"].StaticName].ToString();
    string sBeforeWHQDepartment = item[properties.ListItem.Fields["WHQ Department"].StaticName].ToString();
    string sEmails = string.Empty;
    string sGroups = string.Format("{0},{1},Editors", sAfterRegion, sBeforeWHQDepartment);
     foreach (string group in sGroups.Split(','))
     foreach (SPUser thisuser in properties.Web.Groups[group].Users)
                                    sEmails += thisuser.Email + ";";
                            oSPItem["Subject"] = "Employee Transfer to a Region";
                            oSPItem["To"] = sEmails;
                            oSPItem["Body"] = string.Format("{0} {1} has been transferred to {2} from {3}. Please update EPD ASAP",
    item["First Name"], item["Last Name"], sAfterRegion, sBeforeWHQDepartment);
                            oSPItem.Update();
     else if (sChangedEmployeeType == "WHQ")
     string sBeforeRegion = item[properties.ListItem.Fields["Region"].StaticName].ToString();
     string sAfterWHQDepartment = properties.AfterProperties[properties.ListItem.Fields["WHQ Department"].StaticName].ToString();
     string sEmails = string.Empty;
     string sGroups = string.Format("{0},{1},Editors", sAfterWHQDepartment, sBeforeRegion);
     foreach (string group in sGroups.Split(','))
     foreach (SPUser thisuser in properties.Web.Groups[group].Users)
                                    sEmails += thisuser.Email + ";";
                            oSPItem["Subject"] = "Employee Transfer to a WHQ Department";
                            oSPItem["To"] = sEmails;
                            oSPItem["Body"] = string.Format("{0} {1} has been transferred to {2} from {3}. Please update EPD ASAP",
    item["First Name"], item["Last Name"], sAfterWHQDepartment, sBeforeRegion);
                            oSPItem.Update();
      //send email
      SmtpClient sendEmail = new SmtpClient();
      MailMessage message = new MailMessage();
      sendEmail.Host = "[email protected]";
      message.IsBodyHtml = true;
      message.From = new MailAddress("[email protected]");
      message.To.Add("[email protected]");
      message.Subject = "Test Email on Transfer Jan 13th";
      message.Priority = MailPriority.Normal;
      sendEmail.Send(message);
    catch (Exception ex)
    throw ex;
    This is really frustrating.  Any help is appreciated.
    Talibah C

    Hello,
    Can you debug your solution and let us know the line where your code is failing. Also tell what form you are editing and Is there any checkin/Checkout feature enable on that library?
    BTW i have found two similar threads for same error:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/2096609e-036e-4e5a-bd69-3cded4d3ca89/sharepoint-2010-error-failed-hr-detected-unable-to-update-list-item?forum=sharepointgeneralprevious
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/2277fdab-5652-4627-9879-da199089d6e6/how-can-i-get-around-this-error-when-modifying-a-document-via-itemadded-event?forum=sharepointdevelopmentlegacy
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Get All Values From NewForm.aspx using Event Receiver Item Adding

    HI All,
             I have conditions to check before the insertion of "Calendar Event".For this I am using Item Adding Event Receiver ,When Click on Save button I need to get all the values of Items filled in NewForm.aspx and check
    the condition,If condition satisfies make them insert else show alert info  as"Not Valid",Below is code and error message
    public override void ItemAdding(SPItemEventProperties properties)
                base.ItemAdding(properties);
               string StartTime = properties.AfterProperties["Start Time"].ToString();
               string EndTime = properties.AfterProperties["End Time"].ToString();
    Error
    Object reference not set to an instance of an object.
    Use the New "Keyword to create an object instance
    Can any one help me how can I do it.
    Thanks,
    Quality Communication Provides
    Quality Work.
    http://siddiq-sharepoint2010.blogspot.in/
    Siddiqali Mohammad .

    Hi,
          Have you tried with the code snippet as mentioned below
    string EndDate = Convert.ToString(properties.AfterProperties["EndDate"]);
    string StartDate = Convert.ToString(properties.AfterProperties["EventDate"]);
    If my post is helpful - please click on the green arrow to mark it as answer

  • Error on load: System.IO.IOException: The process cannot access the file : error in event viewer when users want to view documents from this third party deployed scan solution

    Error on load: System.IO.IOException: The process cannot access the file
    '\\server1\SCANSHARED\.pdf' because it is being used by another process.
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
       at System.IO.File.WriteAllBytes(String path, Byte[] bytes)
       at abc.Scan.Layouts.ICC.Scan.View.Page_Load(Object sender, EventArgs e)
    I faced this  error in event viewer  when users want to view documents from this third party deployed scan solution
    here I have two WFS servers  and they configured with load balancing in F5 .
    when I enable both servers in F5 I receive this error messages in 2nd server,
    when users want to view documents
    adil

    Do you have antiVirus installed on the sharepoint servers?
    These folders may have to be excluded from antivirus scanning when you use file-level antivirus software in SharePoint. If these folders are not excluded, you may see unexpected behavior. For example, you may receive "access denied" error messages when files
    are uploaded.
    Please follow this KB and exclude the folders from Scanning.
    http://support.microsoft.com/kb/952167
    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog

  • Sharepoint 2013 ItemAdded event receiver for renaming files is not working

    In SP 2013 I coded an event receiver that intercepts the ItemAdded event and it just renames the file.
    It is a synchronous event (I added <Synchronization>Synchronous</Synchronization> in the Elements.xml).
    This is the code:
            public override void ItemAdded(SPItemEventProperties properties)
                SPSecurity.RunWithElevatedPrivileges(delegate()
                    try
                        OutputDebugStringA("Inside ItemAdded");
                        string szHttpUrl = properties.WebUrl + "/" + properties.AfterUrl;
                        SPWeb openedWeb = properties.Web.Site.OpenWeb(properties.Web.ID);
                        SPFile spf = openedWeb.GetFile(szHttpUrl);
                        EventFiringEnabled = false;
                        string szUrl = properties.AfterUrl;
                        szUrl = szUrl + ".renamed";
                        string szNewFileName;
                        if (szUrl.LastIndexOf('\\') != -1) szNewFileName = szUrl.Substring(szUrl.LastIndexOf('\\') + 1);
                        else if (szUrl.LastIndexOf('/') != -1) szNewFileName = szUrl.Substring(szUrl.LastIndexOf('/') + 1);
                        else szNewFileName = szUrl;
                        if (properties.ListItem != null)
                            properties.ListItem["Title"] = szNewFileName;
                            properties.ListItem.Update();
                        spf.MoveTo(szUrl);
                        EventFiringEnabled = true;
                        base.ItemAdded(properties);
                        OutputDebugStringA("Renaming to " + szUrl);
                    catch (System.Exception exception)
                        OutputDebugStringA("ItemAdded ERROR: " + exception.ToString());
    The problem is that when I upload a .txt file using Internet Explorer, just after the renaming is done, IE says that something went wrong and when I inspect the log files I see:
    SPRequest.GetFileAndFolderProperties: UserPrincipalName=i:0).w|s-1-5-21-4050800873-4278272723-3073177257-500, AppPrincipalName= ,bstrUrl=http://sp2013/sites/demo/subsite1 ,bstrStartUrl=Shared Documents/test2.txt ,ListDocsFlags=16400 ,bThrowException=True 0fa7689c-674b-5045-c3a2-b214a5d4cbed
    01/09/2014 15:29:26.75  w3wp.exe (0x1544)                        0x16F4 SharePoint Foundation        
     General                        ai1wu Medium   System.IO.FileNotFoundException: <nativehr>0x80070002</nativehr><nativestack></nativestack>,
    StackTrace:    at Microsoft.SharePoint.SPWeb.GetFileOrFolderProperties(String strUrl, ListDocsFlags listDocsFlags, Boolean throwException, SPBasePermissions& permMask)     at Microsoft.SharePoint.SPFile.PropertiesCore(Boolean
    throwException)     at Microsoft.SharePoint.SPFile.get_Length()     at Microsoft.Office.RecordsManagement.PolicyFeatures.ApplicationPages.UploadPage.OnSubmit(Object o, EventArgs e)     at Microsoft.Office.RecordsManagement.PolicyFeatures.ApplicationPages.UploadExPage.OnSubmit(Object
    o, EventArgs e)     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)     at System.Web.UI.Page.ProcessRequest(Boolean includeSta... 0fa7689c-674b-5045-c3a2-b214a5d4cbed
    ...gesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)     at System.Web.UI.Page.ProcessRequest()     at System.Web.UI.Page.ProcessRequest(HttpContext context)     at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()    
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)     at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)     at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext
    context, AsyncCallback cb)     at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr
    rootedObjectsPointer, IntPtr nativeRequestContex... 0fa7689c-674b-5045-c3a2-b214a5d4cbed
    ...t, IntPtr moduleData, Int32 flags)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)     at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr
    pHandler, RequestNotificationStatus& notificationStatus)     at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr
    rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)     at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) 
     0fa7689c-674b-5045-c3a2-b214a5d4cbed
    So it is clear that the fact that I renamed the file is causing an issue in the SharePoint upload logic.
    As a solution what I did was to not declare it as Synchronous, but if I do it then there is another error when Sharepoint shows the Edit Properties dialog... in this case the upload is OK but when it is time to show that Edit Property dialog IE fails and
    says that the file has been already modified, or that "something went wrong".
    If I use a synchronous event I get one problem. If I use the asynchronous event I get another problem... It's very frustating and I am pretty sure that a so important API like Event Receivers should have support renaming files so I hope someone can tell
    me what I am doing wrong.
    Thanks in advance

    May be you want to consider using the following code and see if it works for you.
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/40c78e03-2dca-4083-89d2-a7430099da68/how-do-i-change-the-name-property-of-a-file-in-a-document-library?forum=sharepointdevelopment
    Amit

  • Sharepoint 2013, event receiver to rename files not working

    I coded an event receiver (ItemAdding) that renames for example a .txt file to a .text file (it does not matter the extensions, it is just an example). In my code what I do is to an SPFile.MoveTo operation. It works fine in SP2010 but when I execute
    the same code in SP 2013, when the operation is done using IE I get the text "Sorry, something went wrong" and then "File Not Found".
    In the logs this is what I see:
    12/23/2013 15:48:49.16  w3wp.exe (0x17B0)                        0x0AC8 SharePoint Foundation        
     General                        ai1wu Medium   System.IO.FileNotFoundException: The system cannot find the file specified.
    (Exception from HRESULT: 0x80070002), StackTrace:    at Microsoft.SharePoint.SPWeb.GetFileOrFolderProperties(String strUrl, ListDocsFlags listDocsFlags, Boolean throwException, SPBasePermissions& permMask)     at Microsoft.SharePoint.SPFile.PropertiesCore(Boolean
    throwException)     at Microsoft.SharePoint.SPFile.get_Length()     at Microsoft.Office.RecordsManagement.PolicyFeatures.ApplicationPages.UploadPage.OnSubmit(Object o, EventArgs e)     at Microsoft.Office.RecordsManagement.PolicyFeatures.ApplicationPages.UploadExPage.OnSubmit(Object
    o, EventArgs e)     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)     at System.Web.UI.Page.ProcessReque... f72b639c-77b1-5045-c3a2-b23f24ae71c0
    It's clear that the Sharepoint upload code tries to do things with the original name and it does not realize that it was renamed.
    Can I do something from my event receiver code like using the AfterProperties to bypass this error?
    Thanks

    Hi Dennis,
    The issue still persists. Here is the code:
            public override void ItemAdded(SPItemEventProperties properties)
                SPSecurity.RunWithElevatedPrivileges(delegate()
                    try
                        OutputDebugStringA("Inside ItemAdded");
                        string szHttpUrl = properties.WebUrl + "/" + properties.AfterUrl;
                        SPWeb openedWeb = properties.Web.Site.OpenWeb(properties.Web.ID);
                        SPFile spf = openedWeb.GetFile(szHttpUrl);
                        EventFiringEnabled = false;
                        string szUrl = properties.AfterUrl;
                        szUrl = szUrl + ".renamed";
                        string szNewFileName;
                        if (szUrl.LastIndexOf('\\') != -1) szNewFileName = szUrl.Substring(szUrl.LastIndexOf('\\') + 1);
                        else if (szUrl.LastIndexOf('/') != -1) szNewFileName = szUrl.Substring(szUrl.LastIndexOf('/') + 1);
                        else szNewFileName = szUrl;
                        if (properties.ListItem != null)
                            properties.ListItem["Title"] = szNewFileName;
                            properties.ListItem.Update();
                        spf.MoveTo(szUrl);
                        EventFiringEnabled = true;
                        base.ItemAdded(properties);
                        OutputDebugStringA("Renaming to " + szUrl);
                    catch (System.Exception exception)
                        OutputDebugStringA("ItemAdded ERROR: " + exception.ToString());

  • Can't start a 2013 Workflow in an Event Receiver

    I am trying to run a SP2013 workflow from an Event Receiver but I get the error "The request was aborted: The request was canceled. Client ActivityId: aec2fc1b-3f33-44d8-85ab-c6c976617b8c" at the point I actually attempt to start the Workflow.
    The scenario is  as follows. I have 2 lists: List A and List B. Users have permissions to create items in List A but not List B. When users create a new item in List A, a SP2013 workflow runs which then creates a new item in List B. List B should then
    run another SP2103 Workflow but because of how SP and workflows work, this second workflow on List B doesn't automatically run. Thus I have created an Item Added Event Receiver on List B that will run the required workflow automatically (at least it should
    if it worked!)
    I'm sure the problem must be something to do with permissions but nothing I try seems to solve it:
    I can't just use the account of the user triggering the event as this user will be the person adding items to List A and they don't have permissions to do anything in List B (thus they cannot see items in list B or start workflows)
    I can't run using RunWithElevatedPrivileges as a) I don't think this works well with Event Receivers and b) SP2103 workflows cannot be run using the admin account.
    I have tried impersonation with an account specifically set up for running workflows (named mydomain\wssworkflow). This account has full control of the entire site, lists etc. but it still gives the error mentioned above. My code is shown below - the error
    occurs on the line: 
    wfi.StartWorkflowOnListItem(sub, properties.ListItemId, payload);
    Any help in working out why this isn't working would be appreciated.
    Thank you,
    -Stephen
    public override void ItemAdded(SPItemEventProperties properties)
    base.ItemAdded(properties);
    var wsm = new Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager(properties.Web);
    var wfss = wsm.GetWorkflowSubscriptionService();
    var subs = wfss.EnumerateSubscriptionsByList(properties.ListId);
    foreach (var sub in subs)
    if (sub.Name == "RequestAddedToListB")
    var userToken = properties.Web.EnsureUser(@"mydomain\wssworkflow").UserToken;
    using (SPSite site = new SPSite(properties.Site.ID, userToken))
    using (SPWeb web = site.OpenWeb())
    var payload = new Dictionary<string, object>();
    payload.Add("itemId", properties.ListItemId);
    payload.Add("WorkflowStart", "StartWorkflow");
    var wfi = wsm.GetWorkflowInstanceService();
    wfi.StartWorkflowOnListItem(sub, properties.ListItemId, payload);
    break;

    This is the alternate code I had using SPSecurity.RunWithElevatedPrivileges that didn't work. It gives the error 
    "Attempted to perform an unauthorized operation"
    on the line
    var subs = wfss.EnumerateSubscriptionsByList(properties.ListId);
    Thank you.
     public override void ItemAdded(SPItemEventProperties properties)
         base.ItemAdded(properties); SPSecurity.RunWithElevatedPrivileges(delegate
    var wsm = new Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager(properties.Web);
    var wfss = wsm.GetWorkflowSubscriptionService();
    var subs = wfss.EnumerateSubscriptionsByList(properties.ListId);
    foreach (var sub in subs)
    if (sub.Name == "RequestAdded")
    using (SPSite site = new SPSite(properties.Site.ID))
    using (SPWeb web = site.OpenWeb())
    var payload = new Dictionary<string, object>();
    payload.Add("itemId", properties.ListItemId);
    payload.Add("WorkflowStart", "StartWorkflow");
    var wfi = wsm.GetWorkflowInstanceService();
    wfi.StartWorkflowOnListItem(sub, properties.ListItemId, payload);
    break;

  • Attaching remote event receiver to a list on host web.

    We have an O365 Sharepoint 2013 site. I am trying to create a remote event receiver and attach it to a list on host web instead of appweb. Below are the links that I am referencing to do it: 
    http://www.codeproject.com/Articles/636058/Adventures-with-SharePoint-2013-Remote-Event-Recei
    http://blogs.msdn.com/b/knewton/archive/2012/12/11/defining-content-in-host-web-from-an-app-for-sharepoint.aspx
    They are using 'AppInstalled' event to accomplish this. The method is as follows: get the client context of the host web, get our target list in the host web, get the service url of the remote event receiver using code below: 
    string remoteUrl = string.Format("https://{0}/OurRemoteEventReceiver.svc", 
      OperationContext.Current.Channel.LocalAddress.Uri.DnsSafeHost + "/services");
    and then use it while adding an event receiver to our target list. A different way of obtaining this remoteUrl is shown in the second post.
    When I try to do this I get the below error: 
    CorrelationId: eb837c4c-c434-4067-99f4-ad9b38e30d82
    3>        ErrorDetail: The remote event receiver callout failed.
    3>        ErrorType: Transient
    3>        ErrorTypeName: Intermittent
    3>        ExceptionMessage: The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from
    the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.
    3>        Source: Common
    3>        SourceName: Common App Deployment
    Also, the 'Grant permissions to the App' window appears when I hit Deploy and immediately goes away before I hit or even see the 'Trust it' button. Then, after a while I get the above error in output window. This happens whenever I add the 'AppEventReceiver.svc'
    by selecting 'AppInstalled' property to True and then write any code(or even not write any code) in it that targets the host web. Any suggestions please?

    Hi,
    We can add the code snippet below in the "App Installed" event handler.
    EventReceiverDefinitionCreationInformation eventReceiver = new EventReceiverDefinitionCreationInformation();
    eventReceiver.EventType = EventReceiverType.ItemAdding;
    eventReceiver.ReceiverAssembly = Assembly.GetExecutingAssembly().FullName;
    eventReceiver.ReceiverClass = "OurRemoteEventReceiver";
    eventReceiver.ReceiverName = "OurRemoteEventReceiver";
    eventReceiver.ReceiverUrl = "http://xxx/OurRemoteEventReceiver.svc";
    eventReceiver.SequenceNumber = 1000;
    Web web = SPutil.getSP("http://sub.domain.com/sites/apps");
    List targetList = web.Lists.GetByTitle("Host Web List");
    targetList.EventReceivers.Add(eventReceiver);
    web.Context.ExecuteQuery();
    You will need to include an additional .NET class as well:
    using System.Reflection;
    If the problem still existed, I  suggest to debug your remote event receiver project to find the cause of the error. The link below for your reference:
    http://blogs.msdn.com/b/officeapps/archive/2013/01/03/debugging-remote-event-receivers-with-visual-studio.aspx
    More information:
    Add list item properties with a remote event receiver
    http://code.msdn.microsoft.com/office/SharePoint-2013-Add-list-2c6e71e0
    Best Regards,
    Dennis Guo
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

Maybe you are looking for

  • I can no longer add album art work in iTunes version 10.6.0.40

    WHY can I no longer add album art work in iTunes version 10.6.0.40? It is maddening. I have checked many boards and discussion groups but no one has a sure fix. Why is Apple not tending to this problem? They of all groups should know the importance o

  • TAS not defaulted in sales order

    This is a third-party order. In spro, i haved configured as following: Order type "TA" + item cat Group "BANS" + Usage (blank) + High level (blank) = DfItC "TAS", MItCa "TAN", MItCa "TANN", MtCa "TAW" Questions: 1. TAN iso TAS was defaulted when sale

  • Text after each line item in Smartforms.

    Hi , I am developing a smartform for Packlist. i want to display a text like this:: Item    Prodcode           description                   Qty  uom     Picked   Factor             batchNo           batch qty   reel size        to ship             

  • Plug in updates for raw camera with photoshop cs4

    Is there any way to upgrade the above mentioned plug in?

  • How can I overwrite the Last Changed Field (AUFK-AENAM)

    We have an XI application that updates networks in R3 by calling BAPI_NETWORK_MAINTAIN.   The XI RFC Client Parameter has logon user/password that connects to R3, so when a network header is updated by calling the BAPI_NETWORK_MAINTAIN.....then the l