we have a requirement, where i need to check a document which contains documentLists as well in side and almost 50 fields,if any value is missing,i need to write a message with missing field to a Flatfile.
if 4 or 5 fields, we can check using branch step…but out 0f 50 fields if some 20 fields are missing, then i need to collect all the 20 fields and write a message to flatfile with all the details…
Hello,
You may want to consider making a single service that returns “true” if its input is null. Then you should have a MAP step in a second service that takes each input and using the previous service as a transformer, gets the value and populates a String List. Then you can loop over the String List and if the number of “true” values is over your threshold, you can take action. Good day.
Hi Prashanth,
I have coded the below and tested it, it should give you all the fields that are either null or empty. You have to import java.util.ArrayList.
By “if any value is missing” you mean that the document contains all the values even if there are null ? or that missing values are not present in the document ?
In the second way you can’t just loop over the document because the values are not present…
An other approach is to define constraints in the properties of the values in your document: “required → true and allow null → false” where you want to check for missing values.
Then use the “WmPublic/pub.schema:validate” service to validate your doc with the “conformsTo” option with the name of your doc.
You can get the missing values with the “error” document created.