Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

expression language for concatenating

avatar
Expert Contributor

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

1 ACCEPTED SOLUTION

avatar
Master Guru

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.

View solution in original post

5 REPLIES 5

avatar
Expert Contributor

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

avatar
Master Guru

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.

avatar
Expert Contributor

@Matt Burgess Thanks for the prompt reply. I will try and confirm it Thanks again

avatar
Master Guru
@dhieru singh

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

avatar
Expert Contributor

@Shu That worked thanks a lot appreciate it