Often when scripting with getNEXT inside InDesign or InCopy, you may want to work with a specific getNEXT Job. There are two ways to get a specific job: by job path and by XPath.
Example 1: Get getNEXT details about a job by Job Path:
You can think of the Job path as the “breadcrumbs” that will identify a specific job from the root of the hierarchy. So for example, if I want to get job C that is a child of a job B that is a child of job A that is at the root, the job path would be “/a/b/c”.
try { var teObject = app.teGetJobDetails("/a/b/c"); alert ("Object Details" + "\n" + "JobName = " + teObject.teJobName + "\n" + "JobPath = " + teObject.teJobPath + "\n" + "JobWorkingFileName = " + teObject.teWorkingFileName + "\n" + "JobWorkingFileExtension = " + teObject.teWorkingFileExtension + "\n" + "JobId = " + teObject.teId + "\n" + "JobProfileName = " + teObject.teProfileName + "\n" + "JobAssigneeName = " + teObject.teAssigneeName + "\n" + "JobWorkingFileLastModified = " + teObject.teWorkingFileLastModified + "\n" + "JobMediaTypeDelimitedList = " + teObject.teMediaTypeDelimitedList + "\n" + "JobStatusName = " + teObject.teStatusName + "\n"); } catch (err) { alert ("Error: " + err); }
Example 2: Get getNEXT details about a job by XPath:
XPath is is a query language for selecting nodes from an XML document. The XML document used for finding a job is the result of a call to the server to execute a filter. This gets back some set of jobs, and you can use XPath to “navigate” to jobs in that set. The filter must be executed first. Finally, please note that the teGetJobDetailsByXPath() method returns an array of teJobObect.
try { var teFilterResults = app.teExecuteFilter("SampleFilter"); var teObjects = app.teGetJobDetailsByXPath('/ServerResponse/resultList/HierarchyTO/children[1]/HierarchyTO[name="TestJob"]/children/HierarchyTO[name="TestChildJob"]'); for (objectIndex=0; objectIndex < teObjects.length; objectIndex++) { var teObject = teObjects[objectIndex]; alert ("Object Details" + "\n" + "JobName = " + teObject.teJobName + "\n" + "JobPath = " + teObject.teJobPath + "\n" + "JobWorkingFileName = " + teObject.teWorkingFileName + "\n" + "JobWorkingFileExtension = " + teObject.teWorkingFileExtension + "\n" + "JobId = " + teObject.teId + "\n" + "JobProfileName = " + teObject.teProfileName + "\n" + "JobAssigneeName = " + teObject.teAssigneeName + "\n" + "JobWorkingFileLastModified = " + teObject.teWorkingFileLastModified + "\n" + "JobMediaTypeDelimitedList = " + teObject.teMediaTypeDelimitedList + "\n" + "JobStatusName = " + teObject.teStatusName + "\n"); } } catch (err) { alert ("Error: " + err); }
Example 3: Checking out and in a job:
Here we run a filter, check out the first job in the filter, export it’s working file to a folder on the desktop, check the job back in and write a message to the getNEXT Plugin’s log file.
try { var teFilterResults = app.teExecuteFilter("SampleFilter"); var theJob = teFilterResults[1]; var didCheckOut = theJob.teCheckOut(); if (didCheckOut) { var exportFolder = new Folder('/Users/someuser/Desktop/exportTest'); if (!exportFolder.exists) { exportFolder.create(); } var didDownload = theJob.teExportWorkingFile(exportFolder); var theFile = new File(exportFolder + '/'+ theJob.teWorkingFileName); var didCheckIn = theJob.teCheckIn(theJob.teJobName, theJob.teStatusName, theJob.teAssigneeName, false, false, theFile, ["Print"], "A new note"); if (didDownload && didCheckIn) { app.teWriteToLog("Great Success!", TeLogLevelEnum.INFO); } } } catch (err) { alert ("Error: " + err); }