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.

OR

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.

I have an excel lookup table that replaces metadata fields. It has 8 lookup columns. How would I go about combating the “no valid item found” where the majority of fields have replacement data, but some don’t. ie. name, address1 and address2 always have data, but address3 doesn’t. This throws the error

@marrd, can you please share the complete error message and let us know by executing which Workflow plugin it occurs?

Apologies, the excel lookup process isn’t causing the problem in the end. I’m trying to produce output by loading a metadata file, this is what is causing the problem…

Start debugging.
Using schedule for tov

WPROC: tov (thread id: 20088) - 08:23:34

[0055] Starting plugin Metadata File Management - 08:23:34
[0055] Metadata folder: \1.1.1.1\Workspace\tov\metadata
[0055] Parsed metadata folder: \1.1.1.1\Workspace\tov\metadata
[0055] Metadata filename: annual-excel-lookup-addr-update
[0055] Parsed metadata filename: annual-excel-lookup-addr-update
[0055] Plugin Metadata File Management completed successfully - 08:23:36 (elapsed time: 00:00:01.407)

[0057] Starting plugin Metadata Sorter - 08:23:36
[0057] Plugin Metadata Sorter completed successfully - 08:23:36 (elapsed time: 00:00:00.403)

[0058] Starting plugin Create Print Content - 08:23:36
[0058] Source data is MetaData
[0058] Creating the rest client
[0058] [2023-08-15 08:23:38.360] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:38.633] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:39.062] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:39.513] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:39.978] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:40.395] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:40.762] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:41.141] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:41.533] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:41.849] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:42.250] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:42.727] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:43.130] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:43.470] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:43.880] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:44.251] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:44.719] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:45.177] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:45.514] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:45.773] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:46.189] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:46.504] Print content creation> Sent a batch of 25000 fields for update
[0058] [2023-08-15 08:23:46.883] Print content creation> Sent a batch of 20400 fields for update
[0058] Records updated from metadata
[0058] Using cached file (id = 2870006).
[0058] Starting content creation operation…
[0058] [2023-08-15 08:23:47.182] Print content creation> Retrieving results
[0058] W3001 : Error while executing plugin: HTTP/1.1 500 Internal Server Error - An unspecified error occurred which was caused by LoggedApplicationException: There was an error running the content creation process caused by ApplicationException: No record found with ID 2133184 (SRV000022) (SRV000001)
** [0058] Create Print Content: W1603 : Plugin failed - 08:23:47 (elapsed time: 00:00:10.317)**

[0060] Starting plugin Create Job - 08:23:47
[0060] W3001 : Error while executing plugin: W4203 - Metadata does not contain valid Content Item Collection
** [0060] Create Job: W1603 : Plugin failed - 08:23:47 (elapsed time: 00:00:00.038)**

[0062] Starting plugin Create Output - 08:23:47
[0062] W3001 : Error while executing plugin: W4230 - Metadata does not contain a valid Job Item Collection
** [0062] Create Output: W1603 : Plugin failed - 08:23:47 (elapsed time: 00:00:00.041)**

[0063] Starting plugin Send To Folder - 08:23:47
[0063] Path: %{global.baseDir}\tov\Out
[0063] Parsed path: \1.1.1.1\Workspace\tov\Out
[0063] Filename: Annual.pdf
[0063] Parsed filename: Annual.pdf
[0063] File sent : \1.1.1.1\Workspace\tov\Out\Annual.pdf, size: 2685 bytes
[0063] Plugin Send To Folder completed successfully - 08:23:47 (elapsed time: 00:00:00.010)

WPROC: tov (thread id: 20088) complete - 08:23:48 (elapsed time: 00:00:13.221)