OL Learn

Retrieve Items - check if empty?

I have a process which at certain scheduled times does a Retrieve Items, Create Job and Create Output. The Create Job action is showing error W4203: Metadata does not contain valid Content Item Collection. There will not necessarily be any items to retrieve every time that the process runs so instead of producing this error I’d prefer to have a condition immediately after the Retrieve Items to say “If no items received, stop the process”. Is this possible and if so how?

If there is content to be picked up I don’t get the error and if there is no content nothing is output, however it would be neater if the process could stop gracefully rather than logging an error message.

There are a couple of ways to do this.

You could either catch the error in Create Job using the On Error tab which could be instructed to Stop Process.


What I’d likely do is have a Text Condition immediately after the Retrieve Items plugin which simply checks for a property or value in the first Document of the generated metadata and stops any further processing where it doesn’t exist.

So the Text Condition would check for something like:

GetMeta(_vger_prop_myProperty[0], 10, Job.Group[0].Document[0])

is equal to <blank> which then goes to a Delete step so no further processing happens.

NOTE: myProperty is set using Set Properties earlier in the process. Alternatively you could look for a data field (value) in the first document.

Retrieve Items will always return at least one document level in the metadata so this way, we know if we get blank, it has found nothing. Make sure you set the output type in Retrieve Items to metadata to be able to query properties and fields.

Hope this helps.

Hi douglasb, yes it is possible to do so.
When you retrieve items, you could find those in the metadata.
So you can add a condition just after the retrieve item where you would count the number of documents or try to get the value of a specific record.
If you get 0 documents, then you know you can stop the process.
I hope this is helping you.

@Yann - just to challenge my own understanding of this, am I mistaken in thinking you will always get a count of 1 regardless?

yes you are right @jim3108, you will get at least 1 document.
This is a filter plugin that may return 0 document.
So the text condition is the right way :slight_smile:

Thank you both. I now have a text condition that looks for the property immediately after the Retrieve Items action which branches to a Delete if the expected value isn’t found. It appears to work.