validating workflow object
- 6 years ago
Hi David,
These checks aren't required. Validating any result from an item.apply() or AML Query is a good idea, but not always necessary. Since an AML Query can return any number of items, this check is making sure you're only getting a single item.
On top of that, it's better practice to perform these kinds of checks within the query. This will both make your code more manageable, and help ensure you're getting exactly what you need from your queries. If your query is generated through code, you could ensure the source_id / source_type are not null by adding the following lines to your "get" item.
item.setPropertyCondition("source_id","is not null");
item.setPropertyCondition("source_type","is not null");
If you're using AML you can add the following:
<source_id condition="is not null"/>
<source_type condition="is not null"/>
I'd also note that the validation checks could be improved. Instead of workflow.getProperty("source_id", "").Length != 32, just use workflow.getProperty("source_id", "") == ""
AJ