Hello,
I am trying to setup a new rule using Automation for Jira where for any text that matches certain strings, it'll replace this with another text in the comments section:
1) This is my rule and I validated the regex at regex101.com successfully:
2) It then edits the comment field and replaces anything that contains "Nm" : "text" with "":
{
"update": {
{{issue.comments.last.body.replace("\Nm": "([^"]+)\", "")}}
}
}
However my rule is failing with the following message:
Error while rendering additional fields.Failed to get value for issue.comments.last.body.replace("\Nm": "([^"]+)\", "")
I've added a Log Action to my rule and it captures the comment successfully:
Issue comment is: {{issue.comments.last.body}}
LogIssue comment is: {{"PstlAdr": { "Ctry": "BRA", "AdrLine": "Avenida a",dafasdf "TwnNm": "Coa",sdfasdf "CtrySubDvsn": "RadsfadsfasdfO", "PstCd": "00000" }, "CtctDtls": { "Nm": "OaA", "PhneNb": "asdfasdfadsf" } }, "PmtId": { "InstrId": "adsfadsf" }, "PmtTpInf": { "CtgyPurp": { "Prtry": "B" } }, "Purp": { "Prtry": "" }"created_at": "2020-08-06T16:30:25.21Z"}}}
Not sure what the issue could be as the regex matches the correct expression in the comments section.
Any ideas on how to fix this?
Thanks!
Hi Carla,
Automation in Jira does not yet support the ability to edit comments. There is a related thread about this topic over in https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Automation-for-Jira-Can-i-Edit-a-Comment-of-an-Issue/qaq-p/687821 in which Andreas references an existing ticket to track that request over in https://codebarrel.atlassian.net/browse/AUT-419.
Comments are not quite like any of the other fields on an issue in Jira. As such automation does not exactly have a means to edit existing comments just yet. Perhaps you could use automation in order to change some other field on the issue in this manner, but for the time being the comment field works differently in this regard.
I hope this helps.
Andy
Thanks Andy. I have been able to get this to work using regex in Automation for Jira.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have faced the same problems and couldn't find the answers from multiple community posts, so just want to leave a working solution here for somehow who is also struggling:
{
"update": {
"comments": [
{
"edit": {
"id": "{{comment.id}}",
"body": "{{comment.body.substringBefore(\"Fra:\")}}"
}
}
]
}
}
This solution is following the JIRA REST API documentation.
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.