Hello
I have this javascript that I want to output the calculated value to a txt file.
I just do not what to do, I've tried several times with "XSLT transforms", but without any success.
Are there any who can help me?
var theDataset = job.getDataset( "Xml" );
var Stans = theDataset.evalToString( "/Order/Stans" );
var Quantity = theDataset.evalToString( "/Order/Quantity" );
var stansValue = 0;
var ekstraAntal = 0;
var antalSider = 0;
var result = 0;
{
switch (Stans) {
case "001D":
stansValue =2;
break;
case "002D":
stansValue =2;
break;
default:
stansValue;
}
switch (stansValue) {
case 1:
ekstraAntal = 10;
break;
case 2:
ekstraAntal = 6;
break;
default:
ekstraAntal = 4;
}
if (Quantity
How to output calculated value to txt
This looks like it is a script expression. You could output a text file from a script expression, but Switch would not be aware of it and you could not use it in the flow to route it to where it has to go.
You have to create a script using SwitchScripter and in there you write the text file and you send it on to the outgoing connection.
function jobArrived( s : Switch, job : Job )
{
var textFile = new File(s.createPathWithName(job.getNameProper()+".txt"));
textFile.open(File.WriteOnly);
textFile.writeLine("this is a line");
textFile.close();
job.sendToSingle(textFile);
}
Make sure to set the number of outgoing connections of the script to 1.
Freddy
You have to create a script using SwitchScripter and in there you write the text file and you send it on to the outgoing connection.
function jobArrived( s : Switch, job : Job )
{
var textFile = new File(s.createPathWithName(job.getNameProper()+".txt"));
textFile.open(File.WriteOnly);
textFile.writeLine("this is a line");
textFile.close();
job.sendToSingle(textFile);
}
Make sure to set the number of outgoing connections of the script to 1.
Freddy
Hi Freddy,
I have an almost similar need, where I want to output a text-file with information stored in the JobState.
Could a similar script be used to do that and if so, how do I call the information from JobState with the script?
I have an almost similar need, where I want to output a text-file with information stored in the JobState.
Could a similar script be used to do that and if so, how do I call the information from JobState with the script?
Hi Freddy and Dwight,
Based on your previous posts I have created the following script in SwitchScripter:
function jobArrived( s : Switch, job : Job )
{
var textFile = new File(s.createPathWithName(job.getNameProper()+".txt"));
textFile.open(File.WriteOnly);
textFile.writeLine( job.getVariableAsString("[Job.JobState]") );
textFile.close();
job.sendToSingle(textFile);
}
I have set the following properties:
Incoming connections: Yes
Require at least one: Yes
Outgoing connections: One
Require at least one: Yes
Connection type: Move
Execution mode: Serialized
I have saved this script package and loaded it into a Script Element in Switch in a flow with just an incoming and an outgoing folder.
If I place a file in the incoming folder, nothing happens. Where do I go wrong??
Based on your previous posts I have created the following script in SwitchScripter:
function jobArrived( s : Switch, job : Job )
{
var textFile = new File(s.createPathWithName(job.getNameProper()+".txt"));
textFile.open(File.WriteOnly);
textFile.writeLine( job.getVariableAsString("[Job.JobState]") );
textFile.close();
job.sendToSingle(textFile);
}
I have set the following properties:
Incoming connections: Yes
Require at least one: Yes
Outgoing connections: One
Require at least one: Yes
Connection type: Move
Execution mode: Serialized
I have saved this script package and loaded it into a Script Element in Switch in a flow with just an incoming and an outgoing folder.
If I place a file in the incoming folder, nothing happens. Where do I go wrong??
Perfect, Dwight! That was it. Thank you.