This is the area of Switch I have most to learn about.
I have a script made by a previous person and it can error. I think that having a traffic light output connector will help me move the problem jobs away from the good ones.
The script does throw an error (something like an undefined variable or a nullable object is not an instance of an object) so I'm hoping that is enough for it to get pushed down the Error Out connector - but it does not work.
What I did was make a copy of the old script and change the Outgoing Connection Type to Traffic Light
Any tips on what to try next as so far the jobs just hang in the folder before the script
Thanks!
Convert a script to use Traffic Light output
Re: Convert a script to use Traffic Light output
Take a look here:
http://www.enfocus.com/manuals/Develope ... class.html
You will use the sendToData function
http://www.enfocus.com/manuals/Develope ... class.html
You will use the sendToData function
Re: Convert a script to use Traffic Light output
Ah brilliant, thanks.
So where the script is currently producing its error,
Can I just add below
So where the script is currently producing its error,
Code: Select all
throw new Error...;
Code: Select all
sendToData(3);
Re: Convert a script to use Traffic Light output
This script/app is an example of using traffic light connectors: https://github.com/open-automation/swit ... #L274-L280
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore
Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Free Switch apps: open-automation @ Enfocus appstore
Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Re: Convert a script to use Traffic Light output
Thanks Gabriel
your script appears so clean and readable, even though it is still way beyond me I can at least see how you handle your errors.
I have edited the script I had as below and it seems to work in a test. I'm very scared to put it into production though as I'm so inept at scripting.
OLD - Part one where it generates the error
NEW - My guess was to do this
OLD - snip... after it sends a SOAP request and the error is returned it does this
NEW - My guess was to do this
your script appears so clean and readable, even though it is still way beyond me I can at least see how you handle your errors.
I have edited the script I had as below and it seems to work in a test. I'm very scared to put it into production though as I'm so inept at scripting.
OLD - Part one where it generates the error
Code: Select all
try {
job.sendToSingle(job.getPath());
} catch (e) {
}
Code: Select all
try {
job.sendToData( 1, job.getPath() );
} catch (e) {
}
OLD - snip... after it sends a SOAP request and the error is returned it does this
Code: Select all
if (resu !== "Success") {
throw new Error("Invalid response from web service: " + resu);
}
return resu;
}
Code: Select all
if (resu !== "Success") {
//throw new Error("Invalid response from web service: " + resu);
job.sendToData( 3, job.getPath() );
}
return resu;
}
Re: Convert a script to use Traffic Light output
Looks good to me, if what you want to do is, on SOAP error, move the input job into the error connector. Since I can't see the entire script and what ultimately happens to `resu`, I'll offer this suggestion. You likely still want to capture what you were capturing in this exception that was being thrown. Perhaps a log error. Traffic light also supports a log output as well if you wanted to capture the entire SOAP response as a file. This is kind of helpful in some cases (even in success) if you wanted to output an XML result (like the SOAP response) as a log which could be consumed as a dataset later. You can still use the data side of your traffic light for the job (whatever that is).cwswitch wrote: ↑Tue Jan 08, 2019 1:51 am NEW - My guess was to do thisCode: Select all
if (resu !== "Success") { //throw new Error("Invalid response from web service: " + resu); job.sendToData( 3, job.getPath() ); } return resu; }
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore
Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Free Switch apps: open-automation @ Enfocus appstore
Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Re: Convert a script to use Traffic Light output
Awesome thanks, you're very helpful