Hi!
I’m trying to write TLEs to an AFP output with PReS Workflow. Wrinting in the Documents is working in my script below, but I’d like to include page numbers for every page.
I assume, there is a way to do this, as per Document, custom metadata can be made.
Here’s my script, with the currently not working part highlighted as “NOT WORKING”.
SCRIPT--------------------------------------------------------------------------
var xhttp = new ActiveXObject(“MSXML2.ServerXMLHTTP”);
var metaFile = new ActiveXObject(“MetadataLib.MetaFile”);
metaFile.LoadFromFile (Watch.GetMetadataFilename());
var metaJob = metaFile.Job();
var metaGroup = metaJob.Group(0);
var totalPages = 0;
var totalDocs = 0;
var fso = new ActiveXObject(“Scripting.FileSystemObject”);
var contentsetid = Watch.ExpandString(“GetMeta(_vger_contentset_id[0], 10, Job.Group[0])”);
var url = “http://localhost:9340/rest/serverengine/entity/contentsets/” + contentsetid + “/pages?detail=true”;
xhttp.open(‘GET’,url,false, ‘ol-admin’, ‘1234’);
xhttp.setRequestHeader(‘Content-Type’, ‘application/json’);
xhttp.onreadystatechange = handlerGetDataRecord;
xhttp.send();
Watch.SetVariable(“global.totalPages”, totalPages);
Watch.SetVariable(“global.totalDocs”, totalDocs);
function handlerGetDataRecord()
{
if (xhttp.readyState == 4)
{
if (xhttp.status == 200)
{
var contentsetPageDetails = JSON.parse(xhttp.responseText);
var contentsetPageDetailMap = {};
for (var idx=0; idx < contentsetPageDetails.length; idx++)
{
contentsetPageDetailMap[‘’+contentsetPageDetails[idx].id] = contentsetPageDetails[idx].pages.length;
totalDocs++;
fh1.WriteLine(contentsetPageDetailMap[‘’+contentsetPageDetails[idx].id]);
}
for (var idx=0; idx < metaGroup.Count; idx++)
{
var contentItemId = metaGroup.Item(idx).FieldByName('_vger_contentitem_id');
var metaGroupDoc = metaGroup.Item(idx);
metaGroup.Item(idx).Fields.Add('_vger_fld_pndPAGECOUNT', contentsetPageDetailMap[contentItemId]);
metaGroup.Item(idx).Fields.Add('_vger_fld_pndDOCNUMBER', idx+1);
metaGroup.Item(idx).Fields.Add('_vger_fld_pndDOCCOUNT', totalDocs);
metaGroup.Item(idx).Fields.Add('_vger_fld_pndPAGECOUNT', contentsetPageDetails[idx].pages.length);
for (var pageNumber=0; pageNumber<contentsetPageDetails[idx].pages.length; pageNumber++)
{
// __THIS PART IS NOT WORKING__ //
metaGroup.Item(idx).Item(0).Fields.Add('_vger_fld_pndPAGENUMBER', pageNumber+1);
}
totalPages += contentsetPageDetailMap[contentItemId];
}
metaFile.SaveToFile (Watch.GetMetadataFilename());
}
}
}