Created 10-31-2017 01:25 PM
Hi All,
I am creating a new file name based on the time stamp and concatenate with random number but not able figure out the el expression for it
temp_${now():format("yyyy-MM-dd-HH-mm-ss"):join(random():mod(10):plus(1))},
however this expression is not valid EL expression
Thanks
Dheeru
Created 10-31-2017 01:49 PM
The join() function, from the documentation, "may be used only in conjunction with the allAttributes
, allMatchingAttributes
, and allDelineatedValues
functions". I think you want the append() function:
temp_${now():format("yyyy-MM-dd-HH-mm-ss"):append(${random():mod(10):plus(1)})}
I tested this with my EL tester and it seems to work. However you might want to append a dash or underscore before the random digit, as the above expression will put the digit exactly after the number of seconds, unless that's what you want.
Created 10-31-2017 01:37 PM
I tried using this temp_${now():format("yyyy-MM-dd-HH-mm-ss"):join(${random():mod(10):plus(1)})}, this time it is a valid EL expressioon but not generating the random number still
Created 10-31-2017 01:49 PM
The join() function, from the documentation, "may be used only in conjunction with the allAttributes
, allMatchingAttributes
, and allDelineatedValues
functions". I think you want the append() function:
temp_${now():format("yyyy-MM-dd-HH-mm-ss"):append(${random():mod(10):plus(1)})}
I tested this with my EL tester and it seems to work. However you might want to append a dash or underscore before the random digit, as the above expression will put the digit exactly after the number of seconds, unless that's what you want.
Created 10-31-2017 01:51 PM
@Matt Burgess Thanks for the prompt reply. I will try and confirm it Thanks again
Created 10-31-2017 01:53 PM
Join aggregate function works on only attribute values and concatenate those values with the specific delimiter that means
if you are having abc attribute as value hello and xyz having world
${allAttributes("abc", "xyz"):join(" now ")} will result hello now world
i.e all the attribute values got concatenated with now.
If you want to add attribute then use the below EL will result.
temp_${now():format("yyyy-MM-dd-HH-mm-ss")}+${random():mod(10):plus(1)}
without join function will result
temp_2017-10-31-09-48-10+8
Created 10-31-2017 02:51 PM
@Shu That worked thanks a lot appreciate it