createPathWithName problem

Post Reply
Blicksem
Newbie
Posts: 3
Joined: Mon May 02, 2011 9:15 am

createPathWithName problem

Post by Blicksem »

Hello,



A few weeks ago I craeated a simple flow of 2 automanaged folders that are linked through a script element wit the following code:



function timerFired( s : Switch, job : Job){

s.setTimerInterval(3000);

var FlowName = s.getFlowName();

var newFile = job.createPathWithName('Switch_dummy_'+FlowName+ '.xml');

LogFile = new File(newFile);

LogFile.open(File.Append);

LogFile.writeLine('<root>');

LogFile.writeLine('<program>Switch</program>');

LogFile.writeLine('<item>'+FlowName+'</item>');

LogFile.writeLine('</root>');

LogFile.close();

job.sendToSingle(newFile);

}



The intention of the flow, is to create a xml file every 5 minutes and output the file to a folder.



The flow wordek perfect, but now I'm ready to deploy and I get the following error:

27-5-2011 10:50:52,Error,SwitchScript0,test,Create_XML_Timer,,Error in line 5 of script : TypeError. Undefined member function 'createPathWithName' for object 'undefined' of type: 'Undefined'



I have tried to add the code s.createNewJob(); after the s.setTimerInterval(3000);, but it does not help.



Can anybody tell me what I am doing wrong?



With kund regards,



Niels
davidvd
Newbie
Posts: 9
Joined: Fri Feb 18, 2011 11:45 am

createPathWithName problem

Post by davidvd »

Niels,



This cannot work :-)



In your timerFired call, you're using a "job: Job" parameter that doesn't exist. As a timerFired call is called by Switch at regular intervals, but not when a job is present, there is no "job" parameter passed to it. This means you cannot use the incoming job parameter either.



The solution would be to do as you suggest, you'd have to create a new job and use that instead...



Take care,

David.



Blicksem wrote: Hello,



A few weeks ago I craeated a simple flow of 2 automanaged folders that are linked through a script element wit the following code:



function timerFired( s : Switch, job : Job){

s.setTimerInterval(3000);

var FlowName = s.getFlowName();

var newFile = job.createPathWithName('Switch_dummy_'+FlowName+ '.xml');

LogFile = new File(newFile);

LogFile.open(File.Append);

LogFile.writeLine('<root>');

LogFile.writeLine('<program>Switch</program>');

LogFile.writeLine('<item>'+FlowName+'</item>');

LogFile.writeLine('</root>');

LogFile.close();

job.sendToSingle(newFile);

}



The intention of the flow, is to create a xml file every 5 minutes and output the file to a folder.



The flow wordek perfect, but now I'm ready to deploy and I get the following error:

27-5-2011 10:50:52,Error,SwitchScript0,test,Create_XML_Timer,,Error in line 5 of script : TypeError. Undefined member function 'createPathWithName' for object 'undefined' of type: 'Undefined'



I have tried to add the code s.createNewJob(); after the s.setTimerInterval(3000);, but it does not help.



Can anybody tell me what I am doing wrong?



With kund regards,



Niels
Blicksem
Newbie
Posts: 3
Joined: Mon May 02, 2011 9:15 am

createPathWithName problem

Post by Blicksem »

Thanks David,



The reason that it didn't work was because I had to assign the new job to the variable job.

Changing the code s.createNewJob(); in job = s.createNewJob(); was the solution.



Thanks you very much.



Wih kind regards,



Niels
Post Reply