when clients send an email, it's added as a comment in a JSM issue (work item).
since it's coming from an external source, the text "ATTENTION: Ce courriel provient d’une adresse externe. / This message originated outside Company Name." is added to the comment.
I have the following rule, which removes that text from the comment:
however, this leaves some empty space at the top of the comment:
How could i remove this empty space?
I have tried adding another THEN action with currentComment.body.trim() but it didn't work. it added the text that had already been removed by the previous action and didn't remove any empty space. i assume that currentComment hasn't been updated with the changes from my first action, how do i get access to the latest edited comment?
any help is appreciated and thankyou in advance!
It is likely there is a newline, or a carriage return and a newline, at the front of the text.
After you have removed it, add a trim() function at the end of the expression to remove them. The reason the characters cannot be added within the remove() function is because there are multiple ways that blank space could be created.
For example to remove that prefix:
{{comment.body.remove("your prefix text to remove").trim()}}
Kind regards,
Bill
hi @Bill Sheboy thanks for the help :)
I've tried this out:
but that space is still there in the comment:
is there maybe another way to trim the blank space?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is curious...and the trim() should remove the obvious whitespace characters. I tested this repeatedly (with different formatting) with Jira Cloud and it worked as expected.
What version of Jira are you using: Cloud, Server, or Data Center?
Let's find out exactly what is left in there that is causing the extra spacing. Before the comment edit, please add the Log action, and write this expression:
First character code: {{comment.body.remove("ATTENTION: Ce courriel provient d’une adresse externe. / This message originated outside Company Name.").trim().left(1).urlEncode()}}
That will remove your prefix, extract the first character, and display its character code in the log.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Bill Sheboy
I have added the log action before the edit comment action as such:
And this is the log:
a brief google search indicates this is an opening curly bracket? I don't see this anywhere... I tried adding it to the text that is removed but it didn't remove that empty space.
thank you again so much for your help! already learning a ton,
Carla
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.
I agree: there does not appear to be a left-curly bracket in that comment text.
The last thing to try is immediately after the trigger, log the entire comment to evaluate what it shows, comparing that to what you are checking:
full comment body: >>{{comment.body}}<<
I added some surrounding greater-than and less-than characters to help us see if there is anything else at the front or back.
If that contains exactly what you expected with no extraneous characters, I recommend asking your Site Admin to check with the Atlassian Support team to learn what they suggest: https://support.atlassian.com/contact/#/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
aha! there's some color coding!
when seeing this message in outlook, it looks like:
this explains why the trim wasn't working!
I've tried to add those characters to the .remove string but it didn't work. I guess it's cause they're "invisible". do you know if there's a way to convert those to text?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Awesome! Let's try to remove the markup with the .text function:
{{comment.body.text.remove...}}
If that does not help, we will need to resort to a regular expression and the replaceAll() function to remove your prefix text.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
THAT WORKED!!!!
YAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Awesome; I am glad to learn it is working now!
Please consider marking this question as "answered" to help others with a similar need find solutions faster. Thanks!
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.
Hi @Carla Gonzalez
I ran a test and got it working by using this smart value in the "Edit comment" action:
{{currentComment.body.remove("ATTENTION: Ce courriel provient d’une adresse externe. / This message originated outside Mira Geoscience.\n").trim()}}
Let me know if this works on your side too!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi @Anthony Morais thanks for the quick reply!
I've tried {{currentComment.body.remove("ATTENTION: Ce courriel provient d’une adresse externe. / This message originated outside CompanyName.\n").trim()}}
but it doesn't seem to have correctly found the text in the comment, since it didn't remove it from the comment:
I removed \n and this time it did find it and removed it:
but the trim seems to not have done anything. do you know why that may be? maybe i could use something other than trim?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.