I have a JDF (created via the HP JDF Control configurator) that has a dataset attached to it.
I'm trying to create a simple text file for use elsewhere but I keep getting the error:
Error in line 11 of script : TypeError. 'ToString' undefined or not a function
Invalid XML document
Below is the script. Can anybody see what I've done wrong??
function jobArrived( s : Switch, job : Job )
{
var dataset = job.getDataset("XML");
var xml = new Document(dataset);
var JobCode = dataset.ToString("/Job/@JobCode")
var textFile = new File(s.createPathWithName(JobCode));
textFile.open(File.WriteOnly);
textFile.writeLine("Add to Digital");
textFile.writeLine("Indigo");
textFile.close();
job.sendToSingle(textFile);
job.sendToSingle(textFile.fullName);
}
Thanks
Andrew
using metadata in a new file
Re: using metadata in a new file
Code: Select all
var dataset = job.getDataset("XML");
Code: Select all
var xml = new Document(dataset);
Code: Select all
var JobCode = dataset.ToString("/Job/@JobCode")
Code: Select all
var JobCode = xml.evalToString("/Job/@JobCode");
Re: using metadata in a new file
Hi Freddy,
Thanks for that, but I must be missing it still as the changes still error. Here's what I've got:
var dataset = job.getDataset("XML");
var xml = new Document(dataset.getPath());
var JobCode = xml.evalToString("/Job/@JobCode");
var textFile = new File(s.createPathWithName(JobCode));
I still get the same error
Error in line 11 of script : TypeError. Undefined member function 'ToString' for object 'undefined' of type: 'Undefined'
Any ideas
Andrew
Thanks for that, but I must be missing it still as the changes still error. Here's what I've got:
var dataset = job.getDataset("XML");
var xml = new Document(dataset.getPath());
var JobCode = xml.evalToString("/Job/@JobCode");
var textFile = new File(s.createPathWithName(JobCode));
I still get the same error
Error in line 11 of script : TypeError. Undefined member function 'ToString' for object 'undefined' of type: 'Undefined'
Any ideas
Andrew
Re: using metadata in a new file
As I do not know which of the lines is line 11 it is hard to say anything conclusive.
Are you sure the name of the dataset is "XML"? Add
after the line where you initialize the dataset variable to see if what you get is a Dataset object or undefined. My guess is that you get undefined in which case xml will also be undefined and evalToString does not work. But you should see other errors as well as the XML file cannot be loaded.
Are you testing this in Switch Scripter or in a flow? When in a flow, do not forget to stop and start the flow again or your changes are not taken into account.
Are you sure the name of the dataset is "XML"? Add
Code: Select all
s.log(1,dataset);
Are you testing this in Switch Scripter or in a flow? When in a flow, do not forget to stop and start the flow again or your changes are not taken into account.
Re: using metadata in a new file
I checked the dataset name and it is "XML".
After adding in the log command I get a warning about an invalid XML document.
I decide to export the XML to a new dataset and get the script to read that newly created dataset but it still errors.
All this is done within the flow and it is being stopped/started each time
After adding in the log command I get a warning about an invalid XML document.
I decide to export the XML to a new dataset and get the script to read that newly created dataset but it still errors.
All this is done within the flow and it is being stopped/started each time
Re: using metadata in a new file
Then you should investigate if the dataset with the name "XML" is actually an XML file. Go to the application data root folder (you find the path in the Preferences) and based on the time of the file you should be able to find the dataset backing file quite easily in the folder "datasets".
How is the dataset added?
How is the dataset added?
Re: using metadata in a new file- SOLVED
All working fine now. The amends to the script didn't take in the flow even after stop starting... came back to it an our later and it all processed OK with no further changes.
No on to something new
No on to something new
