Developer forum

Forum » Development » Get current area in backend

Get current area in backend

Lars Larsen
Lars Larsen
Reply

Hi

I want to get the itemtype associated with the area that the editor is editing in the backend. How can that be done? I would very much like to get it from within the notification "ItemNotification.Saving".


Replies

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply

Hi Lars,

If you want the item type system name for the item being saved then you can get it like this...

var itemArgs = (ItemNotification.ItemUpdateArgs)args;
var item = itemArgs.ToItem(itemArgs.Item);
if (item != null)
{
    var itemType = item.SystemName;
}

Alternatively you can implement a notification subscriber for OnBeforeAreaSaved / OnAreaSaved and then check the area.ItemType property.

Is that what you need or is it something else? A description of what you are trying to achieve would be very helpful :)

Best regards,
Morten

 

 

You must be logged in to post in the forum