properties.Cancel = true not firing in ItemAdded event

Mina Samy
  • properties.Cancel = true not firing in ItemAdded event Mina Samy

    I developed a custom event receiver class that overrides the ItemAdded method

    after the list item is added I want to make some checks and based on a certain condition I want to delete the added item.

    I was able to delete the item but i want to display an error message so I used

    properties.Cancel = true; 
    
    properties.ErrorMessage = "Can't insert this item";
    

    when I debugged I found no errors but the user is not directed to the error page.

    is there any workaround for this ?

    thanks

  • Since you are using ItemAdded in SharePoint 2007 that event is asynchronous and happening after the item is added. Asynchronous means that it will happen "behind the scenes", ie you cant redirect the user to an error page. Instead try to use the ItemAdding if you need to cancel the event and present an error message for the user.

Tags
event-handlers 2007
Related questions and answers
  • ;Switch> statement after <Subject> The Item Added message is (in Fields -> Switch -> Case Value="1") is repeated thrice Is something wrong with above template that is prompting SharePoint...I've customized alert notification template for Announcements list. Here is custom code: <Immediate> <Subject> <Switch> <Expr> <GetVar Name...; <Case Value = "1"> <HTML> <![CDATA[A new content has been added to Latest Events. To view, please visit: <a href

  • does activate the webpart but i also want to remove it when deactivating it.(So i know i need to add something to the FeatureDeactivating So i created a Feature With Reciever template and added...(".")); // delete web parts that have been added if (webpartName == "myStoreComms") { list.Items[i].Delete(); break... deactivate it it doesn't remove it but i get error: Failed to instantiate file "myStoreComms.webpart" from module "WebPartPopulation": Source path "myStoreComms.webpart" not found. Any ideas.. .what

  • I have been developing on SP 2010 for a while now. Mostly I have been working with the Client Object Model. Though I am at a point where I need to read out the UserProfiles from inside SharePoint. I see no other way to do this than to make a custom WCFService and deploy it to SharePoint. So that is what I did. I made an "Empty SharePoint Project" and added the mapped "ISAPI" folder. The code...; } This service gives a TimeOut error... When I delete the following line the TimeOut is fixed if (profile["FirstName"] != null) { } So I can only read out

  • %252F [4,["\n \n sdja",["\n \n sdja","","",-1],[true,[["","",0,"",0,[]],["sdja","",0,"",1,[["John Doe","CONTOSO\\sdja",1,"John Doe",""]]]],false],false,false,false],-1,false,false],[5...;V1_I1_CP2;;T_sdja_%252F%252F0%252F%252F [4,["\n \n sdja",["\n \n sdja","","",-1],[true,[["sdja","",0,"",0,[["John Doe","CONTOSO\\sdja",1,"John Doe",""]]]],true],false,false,false],-1,false,false],[5,["\n \n ",["\n \n ","","",-1],[false,[],true],false,false,false],-1,false,false], Contact Selector Information about the control can br found on the InfoPath team blog: Using

  • happening. When I activate ContentTypes, the content type and field are deployed as expected into my site collection. When I activate Registration, the list is provisioned and the content type is added as expected. When I try to add a new item to the list, the list form only shows the Title field from Item. Now, here's the weird part. If I add a second content type to the list (through the UI... xmlns:ows="Microsoft SharePoint" Title="Withdrawals" FolderCreation="FALSE" Direction="LTR" Url="Lists/Withdrawals" EnableContentTypes="TRUE" BaseType="0"> <MetaData> <ContentTypes>

  • I've created a Custom List ('Tooltips') in SharePoint. After this I used SPSource to reverse engineer the list into a feature. After installing and activating this feature, I want to add this list in a WebPart zone. When doing this, I get an error message : Tooltips: List View Web Part could not be added, list may be hidden. What's wrong with the list? feature.xml <?xml version="1.0" encoding="utf-8"?> <Feature Id="70d49f3d-233a-482d-97e3-dcec2c236171" Title="MyApp - Tooltips" Description="Creates a Tooltips list which can be used for mouse-over texts

  • I want to show the contents of three specific columns from one specific list item. Like Meeting list item ID 5 contains Name MeetingDate Bitfield1 Bitfield2 John Doe 23-06-2010 Yes No In a web part (if possible) I want to create this view: Meeting Date: 23-06-2010 Bitfield1: Yes Bitfield2: No (Edit link to Meeting list item ID 5) Is that possible without coding a web part from scratch? E.g. with the XML web part or others? (solution is MOSS 2007 Enterprise based if that's relevant)

  • I want to create a new SharePoint 2010 farm using PowerShell. I use the following command: New-SPConfigurationDatabase When issuing this command (and providing the needed parameters) I get the following error: New-SPConfigurationDatabase : This SharePoint farm currently has pending upgrades. The cmdlet New-SPConfigurationDatabase cannot be executed until the upgrade is completed. When running the "SharePoint 2010 Products Configuration Wizard" I'm able to create a farm. I have a freshly installed Windows Server 2008 R2 with SQL 2008 R2 on the same box (it's a demo box

  • + ASP.Net + SharePoint Server 2007 SDK. Here is my code snippets and I got error -- "Updates are currently disallowed on GET requests". Any ideas how to fix? Microsoft.SharePoint.SPException: Updates..."); } catch (Exception ex) { Response.Write(ex.ToString() + "\t" + ex.StackTrace); } } Update 1: I met with the same error with the following code, SPContext.Current.Web.AllowUnsafeUpdates = true; SPWebApplication webApp = SPContext.Current.Site.WebApplication; SPSiteCollection siteCollections

Data information