Grab shifting text value in Data Mapper

I have a text file where the PO Number and Date shift around by a few lines and columns. Otherwise the data is stable and consistent.

Both the PO Number and Date have a consistent Tag (“Date:” or “PO #”) that will help finding the proper line.

Date:                mm/dd/yyyy

PO #                 S00003456

Or like this with extra lines and different columns

Date:            mm/dd/yyyy



   PO #                     S00003456

I’m not having any success extracting the value and wondering if anyone has a sample script that would be similar that will work in the data mapper?

This appears to work

ExampleZone

Didn’t we cover an almost identical topic in Simulate PP7 Line Condition - DataMapper - Upland OL User community?

Yes, good point it is somewhat similar. With this one the two items are floating around within a zone so I was taking a different approach. The script works as long as there is always a Date: in the zone. If the Date: falls outside the zone or is missing I get a Cannot call method “indexOf” of undefined: 1 error .

Your code takes for granted that there are always 8 lines in the data you’re extracting ( “for(i=0;i<=7;i++)”). So if there are only 7 items, then Zone[7] is undefined… which is why you get an error stating the method indexOf() cannot be called for undefined. You loop logic should be:

for(i=0;i<Zone.length;i++)