Page 1 of 1

easy script for rename job flow element?

Posted: Tue Nov 28, 2017 4:38 pm
by Fist
I have a .csv file which need to be renamed by using a parameter in that .CSV.
I would need a script expression to do this.

It should be like:

if tag <MyParam> contains yes
then add prefix Y
else add prefix N

Can anyone translate it into a propre javascript expression?

Thanks!

Fist

Re: easy script for rename job flow element?

Posted: Mon Dec 04, 2017 1:08 pm
by Padawan
This Script Expression will search for SearchString in the current job. You can use this Script Expression in the Rename Job element to choose which prefix to add.

Code: Select all

var fileContent = File.read(job.getPath(), "UTF-8");
var theReturn;

if (fileContent.find("SearchString") > 0)
{
	theReturn = "Found";
}
else
{
	theReturn = "NotFound";
}
theReturn;