Email Template -subject error -Operation not allowed as you are entering a value that resembles

IAM_99
Regular Contributor II
Regular Contributor II

hi Team , We are copying this in email template subject line it give below error popup.

Operation not allowed as you are entering a value that resembles or contains script code

whats wrong with below  ?

<% if(null!=user?.customproperty51 || user?.customproperty51!='') print "${java.text.SimpleDateFormat('dd MMM yyyy').format( java.text.SimpleDateFormat('yyyy-MM-dd').parse(java.time.LocalDate.now().plusDays(Integer.valueOf(user.customproperty51)).toString()))}" %>

11 REPLIES 11

rushikeshvartak
All-Star
All-Star

parse format keyword are blocked

IAM_99
Regular Contributor II
Regular Contributor II

Okay, any other way to format the date in subject ?

Try below

<% if(null!=user?.customproperty51 || user?.customproperty51!='') print "${java.text.SimpleDateFormat('dd MMM yyyy').format(new Date().plus(Integer.valueOf(user.customproperty51)))}" %>

or

<% if(null!=user?.customproperty51 || user?.customproperty51!='') print "${java.text.SimpleDateFormat('dd MMM yyyy').format(Date().plus(Integer.valueOf(user.customproperty51)))}" %>


Regards,
Saathvik

IAM_99
Regular Contributor II
Regular Contributor II

tried getting this error

 

println.PrintlnToLogger - Println :: \u001b[1;31m| Error \u001b[22;39mgroovy.lang.MissingPropertyException: No such property: java for class: SimpleTemplateScript416\u001b[m\n","stream":"stdout","time":"2023-01-26T15:37:52.218005562Z"}

IAM_99
Regular Contributor II
Regular Contributor II

this worked with new keyword

<% if(null!=user?.customproperty51 || user?.customproperty51!='') print "${new java.text.SimpleDateFormat('dd MMM yyyy').format(new Date().plus(Integer.valueOf(user.customproperty51)))}" %>

Great can you mark the helpful answers and close the thread if issue is resolved


Regards,
Saathvik

IAM_99
Regular Contributor II
Regular Contributor II

I am getting "Operation not allowed as you are entering a value that resembles or contains script code" while saving for below  in the subject

<% if(user?.customproperty51=='5') print "Disabled" else print "Deleted" %>

Can you try with below statement with advanced html checked?

 <% if (user?.customproperty51=='5') print "Disabled" else print "Deleted" %> 

 I did try on my side and didn't see any issue in saving email template 

sk_0-1674749995858.png

 


Regards,
Saathvik

IAM_99
Regular Contributor II
Regular Contributor II

This worked below , it seems length of the subject not taking more than 255 chars.

Action Required - Your Equifax account will be ${user?.customproperty51=='5'?"Disabled":"Deleted"} on ${new java.text.SimpleDateFormat('dd MMM yyyy').format(new Date().plus(Integer.valueOf(user.customproperty51)))}

IAM_99
Regular Contributor II
Regular Contributor II

can you try saving below 

DEV - Action Required - Your Equifax account will be <% if(!user?.customproperty51 && user?.customproperty51=='5') print "Disabled" else print "Deleted" %> on <% if(null!=user?.customproperty51 || user?.customproperty51!='') print "${new java.text.SimpleDateFormat('dd MMM yyyy').format(new Date().plus(Integer.valueOf(user.customproperty51)))}" %>

Above statement is failing because it crossed the limit of subject column(varchar(255)). Try to trim your statement as below so that it can work

DEV:Action Required - Your Equifax account will be ${user?.customproperty51=='5'?"Disabled":"Deleted"} on ${(!user?.customproperty51)?(new java.text.SimpleDateFormat('dd MMM yyyy').format(new Date().plus(user.customproperty51.toInteger())))}


Regards,
Saathvik