I am trying to figure out how to check if a component is null (e.g. not found in Tridion) in a custom backend. I just donβt see how to check this, except to catch the error.
Component comp = (Component)session.GetObject(base.ComponentUri);
if (component != null)
{
bool isCheckedOut = component.IsCheckedOut;
}
else
{
}
I am 100% sure that uri is correct ('tcm: 113-438134') and 100% sure that there is no element with this URI in Tridion. The above code throws an error in the .IsCheckedOut component:
The item tcm:113-438134-16 does not exist.
How to check for a Tridion element? I tried to put a throw at the end, which did not help:
Component comp = session.GetObject(base.ComponentUri) as Component;
and I tried not to use at all, but using IdentifiableObject, which also didn't make any difference. Does anyone know how to do this?
source
share