Highlighted
Respected Contributor.
Respected Contributor.
418 views

Counting number of elements in 1 event attribute

Jump to solution

i want to count the number of elements which is being seperated by ";" from one event attribute then matching the rule to take an action.

For example: receiving an event which having attribute "Sent to" containing number of email addresses (a@company.com; b@company.com; c@company.com). Now, I would like to create a rule basing on the number of email address in "Sent to" attribute. If this event is containing more than 3 elements within "Sent to" attribute then rule will fire an action like notify to admin.

Can you please advice how we can achive this function?

0 Likes
1 Solution

Accepted Solutions
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Hi,

With the recent ESM version from 6.8, it is very easy to do this. Due to the new features.

I have not seen your event thus I will be very generic. Adapt my answer with your real data.

1) you need to extract all email addresses; you can use IndexOf and Substring functions for this. It is to remove "Sent to:" and blank chars.

2) you have to convert the email addresses string into a list with the convertStringToList function and you choose ; as the separator

3) you finally create a last variable in using the getListSize function to calculate the number of elements in your list

4) in your rule, you will trigger if the variable above is >= 3

Do not hesitate to contact me, if you have any question or if you have not succeded to build this use case in following my explanation.

Regards,

Michael

View solution in original post

3 Replies
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Hi,

With the recent ESM version from 6.8, it is very easy to do this. Due to the new features.

I have not seen your event thus I will be very generic. Adapt my answer with your real data.

1) you need to extract all email addresses; you can use IndexOf and Substring functions for this. It is to remove "Sent to:" and blank chars.

2) you have to convert the email addresses string into a list with the convertStringToList function and you choose ; as the separator

3) you finally create a last variable in using the getListSize function to calculate the number of elements in your list

4) in your rule, you will trigger if the variable above is >= 3

Do not hesitate to contact me, if you have any question or if you have not succeded to build this use case in following my explanation.

Regards,

Michael

View solution in original post

Highlighted
Respected Contributor.
Respected Contributor.

Thank you Michael 🙂 Your suggestion works on our environment 😄

Regards,

Anh

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

You can also use just one velocity variable that looks like this

#set($tempvar=$sourceUserName)$tempvar.replaceAll('[^\,]','').length()

replace the sourceUserName with the field you want to evaluate

Replace the , here ('[^\,]','').length()    with your delimiter

marked in red

Best regards

David

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.