Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
If it's empty I'd imagine it'll be ContentReference.Empty so I'd suggest writing and exclude filter for any that match that.
query = query.Filter(x => !(x as NewsroomDetailPage).Asset.Match(ContentReference.Empty)); should work as Scott suggested
or you can write something like
public static FilterExpression<ContentReference> IsEmpty(this ContentReference value)
{
return new FilterExpression<ContentReference>(x => ContentReference.IsNullOrEmpty(x));
}
We have "NewDetailPage" and it has an 'asset type' field. Asset type field is ContentReference type.
Now we are showing two kinds of assets in the find results by following the below approach.
query = query.FilterByExactTypes(new List<Type> { typeof(NewsroomDetailPage) });
query = query.Filter(x => !(x as NewsroomDetailPage).Asset.Match(new ContentReference(22))); // news releases
query = query.Filter(x => !(x as NewsroomDetailPage).Asset.Match(new ContentReference(9987))); //videos
But how can we exclude the if the Asset Type field was empty?