startsWith condition not working in Email subject

Hello Colleagues,

I am attempting to stop email notifications for certain access profiles. I have implemented the following condition in the email template subject, but it is not functioning as intended:

#if(${accessProfileName}.startsWith(‘ABC’))#stop#end Your Access Request for ${accessProfileName} has Been #if($approved)Approved#{else}Denied#end

Additionally, the .contains operation is also not yielding the desired results. However, using the equality operation works correctly, as shown here:
#if(${accessProfileName} == “ABC - Access profile full name”))#stop#end

I would appreciate any suggestions you may have to enable the use of the .startsWith() operation in the email subject.

Hi @ag2024,

Even if startsWith is working this will send email as you are using #end after #stop. So it again sends email using subject after #end.

Can you try this.

#if(${accessProfileName}.startsWith(‘ABC’))#stop#elseif Your Access Request for ${accessProfileName} has Been #if($approved)Approved#{else}Denied#end#end

Thanks.

1 Like

Hi @ag2024
I don’t think you can use conditional functions like startsWith directly on objects in email templates

Try something like this:

#set($accessProfileName=${accessProfileName})#if($accessProfileName.startsWith(‘ABC’))SUCCESS#{else}FAIL#end

Let me know if to works :slight_smile:

2 Likes

@sk8er23
Could you please provide guidance on where to utilize the #stop function and how to specify the email subject for others access profiles (not starting with ABC)?

#set($accessProfileName=${accessProfileName})#if($accessProfileName.startsWith(‘ABC’))#stop Your Access Request for $accessProfileName has Been #if($approved)Approved#{else}Denied#end**

1 Like

startsWith working now. Thank you @sk8er23

Perfect good to hear :slight_smile:

1 Like