Note that there are some explanatory texts on larger screens.

plurals
  1. POitem.Delete() gives Object reference not set to an instance of an object error in Sitecore
    primarykey
    data
    text
    <p>In my Sitecore application I have the below statements.</p> <pre><code>using (new Sitecore.SecurityModel.SecurityDisabler()) { Item item = database.GetItem(itemId); if (item != null) { item.Delete(); } } </code></pre> <p>The <code>item</code> object is not null and in <code>item.Delete();</code> statement the error occurs. Can anyone tell whats wrong with this issue?</p> <p><strong>Updated:</strong> Stack trace</p> <pre><code> at Sitecore.Tasks.ItemEventHandler.OnItemDeleted(Object sender, EventArgs args) at Sitecore.Events.Event.EventSubscribers.RaiseEvent(String eventName, Object[] parameters, EventResult result) at Sitecore.Events.Event.EventSubscribers.RaiseEvent(String eventName, Object[] parameters) at Sitecore.Events.Event.RaiseEvent(String eventName, Object[] parameters) at Sitecore.Events.Event.RaiseItemDeleted(Object sender, ItemDeletedEventArgs args) at Sitecore.Events.Event.DataEngine_ItemDeleted(Object sender, ExecutedEventArgs`1 e) at System.EventHandler`1.Invoke(Object sender, TEventArgs e) at Sitecore.Data.Engines.EngineCommand`2.RaiseExecuted() at Sitecore.Data.Engines.EngineCommand`2.Executed() at Sitecore.Data.Engines.EngineCommand`2.Execute() at Sitecore.Data.Engines.DataEngine.DeleteItem(Item item) at Sitecore.Data.Managers.ItemProvider.DeleteItem(Item item, SecurityCheck securityCheck) at Sitecore.Data.Managers.ItemManager.DeleteItem(Item item) at Sitecore.Data.Items.Item.Delete(Boolean removeBlobs) at Sitecore.Data.Items.Item.Delete() </code></pre> <p>I have further found that the item is actually got deleted from the Sitecore tree, and then gave the error.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload