I am trying to get the metadata field names of the first document in the first group of my metadata file. I am using the below script but all it returns is one field name: _vger_record_id
var myMeta = new ActiveXObject(“MetadataLib.MetaFile”);
myMeta.LoadFromFile(Watch.GetMetadataFileName());
var myGroup = myJob.Group(0);
var myDoc = new Enumerator(myGroup).item();
var fieldcount = myDoc.Count;
Watch.Log('fieldcount: ’ + fieldcount,2);
for(var x = 0; x < fieldcount; x++){
Watch.Log('Field ’ + x + ': ’ + myDoc.fields.Name(x),2);
}
I think I was too quick :-)…
I am having some issues selecting the correct group because just before this script there is a metadata filter which filters the metadata base on the number of pages in the group.
This script seems to get the first metadata document in the original metadata file but not in the filtered one, yielding incorrect result.
Is there a way to get the first document within the new filtered metadata structure as the index will not always be 0 in this case?
The process does the following:
Filter metadata
Split metadata on Group level
Then run this script to get all field names and values in a json which I will send to a third party app. So it’s dynamic.
Getting the value of the filtered metadata document filed with
Watch.ExpandString(“GetMeta(” + myFields.Name(x)+ “[0], 10, Job.Group[0].Document[0])”);
seems to work now.
Am I doing it correctly or there an issue in obtaing the values these way in this case?
Yep, that’s the proper way of doing it: by splitting on metadata, you are essentially creating metadata chunks, and on each iteration, the fields you are looking for are on Document[0] of that chunk.