I trying to produce an groovy email post function where a cfValue is assigned to a string, then remove a portion of the string and then place in the html email. Below is the"Email template" with the "Email format" set to HTML, and the current output.
<html> <body> <b>Summary: </b><% out << issue.summary %><br> <b>Separating user: </b><% out << cfValues['Separating user'] %> = Please ignore the :####<br>
<b>UID of Separated: </b><% out << cfValues['UID of Separated'] %><br> <b>Reports To: </b><% out << cfValues['Reports To'] %><br> <b>Manager's UID: </b><% out << cfValues['Manager\'s UID'] %><br> <b>Work Location: </b><% out << cfValues['Work Location'] %><br> <b>Other Work Location: </b><% out << cfValues['Other Work Location'] %><br> <b>Effective Date: </b><% out << cfValues['Date Requested'] %> </body> </html>
Summary: Separation of Cubicle Monkey
Separating user: klynch:10000 = Please ignore the :####
UID of Separated: test1234
Reports To: klynch:10000
UID: test4321
Work Location: CA02 (GBR) (611 N Brand Blvd, Glendale, CA 91203)
Other Work Location: NA
Effective Date: 2013-03-29 00:00:00.0
I want the Separating user: and Reports To: output to be (no :10000) at the end
Summary: Separation of Cubicle Monkey
Separating user: klynch
UID of Separated: test1234
Reports To: klynch
UID: test4321
Work Location: CA02 (GBR) (611 N Brand Blvd, Glendale, CA 91203)
Other Work Location: NA
Effective Date: 2013-03-29 00:00:00.0
I've tested string replacement with and the output it correct
<script type="text/javascript"> var str = "klynch:10000"; var n = str.replace(":10000",""); document.write(n); </script>
output shows klynch without the :10000
I tried adding the following inside the body, but it outputs nothing in return and I'm not seeing anything in the log as to why or any error.
<script type="text/javascript"> var str = cfValues['Separating user']; document.write(str); var n = str.replace(":10000",""); document.write(n); </script>
I'm assuming that the cfValues['Separating user'] does not work inside the script tag. How do I get it so that the cfvalue can be stripped of it's :10000 at the end and then placed in the email correctly.
Thanks
Javascript is not groovy... so not sure what your JS snippets demonstrate.
Is the "Separating user" field a user custom field? If so you can get the username by just appending .name ie cfValues['Sep User'].name. This would be better than doing string manipulation.
Otherwise you could do cfValues[x].split(":").getAt(0)
but you will get an exception if no value is filled.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Np. If you used the former you should probably do:
cfValues['Sep User']?.name
This will just return null if the user field is null, without throwing a null pointer exception.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.