Hi,
Is it possible to add some text into a screen like create issue screen ?
Joseph
Community moderators have prevented the ability to post new answers.
Not off-the-shelf, but if you've got the Jira Toolkit plugin, you can add message fields that you can then fill with text.
Hi Nic,
How can I get JIRA Toolkit plugin?
regards,
Bhavesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
From the "find new add-ons" admin section in admin, or the marketplace.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bernard,
I will post here the complete solution.
Step 1: In order to add an automatically generated comment during the transition from in progress to resolved, edit the workflow and in the resolved step: Add in the beginning Post function > Custom Script Function and the inline script copy - paste the code
import com.atlassian.jira.component.ComponentAccessor def commentManager = ComponentAccessor.getCommentManager() def user = ComponentAccessor.getJiraAuthenticationContext().getUser() if (issue.getSubTaskObjects().any { !it.getResolutionObject() }) { log.debug("There are Unresolved sub-tasks") commentManager.create(issue, user, "I resolved this issue even though there were unresolved sub-tasks... slapped wrists", false) }
This script will automatically add a comment to the resolved issue.
Step 2: In order to automatically send an email, add a second Post function > send a custom email and fill the information you want. For example copy the script in the email template area
Dear <% out << issue.reporter?.displayName %>, The $issue has been resolved <% def commentManager = com.atlassian.jira.component.ComponentAccessor.getCommentManager() def commentsList = commentManager.getComments(issue) def commentsBody = "<br>" for (comment in commentsList) { commentsBody += comment.getBody() + "<br>" } out << commentsBody %> Regards, <% out << issue.assignee?.displayName %>
will send an email with all the comments in the body, (you can preview the message before save it)
Dear <issue reporter name>, The EPF-1 has been resolved This is an automatically generated comment I added this comment Regards, <issue assignee name>
then move this post function just before the 'fire a generic event', and publish the new workflow.
The custom email is highly configurable.
Please let me know if this solution works for you and if you have any further questions.
Kind regards
Thanos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thanos,
Thanks for this Scriptrunner code example.
Sorry for my delay in replying but it is only now that I have had a chance to try it.
I got the scriptrunner comment code (step 1) working and can see that it adds a separate comment to the issue.
Is there a way to auto-add your additional comment into the same comment area as the resolution fix comment, rather than have 2 separate comments?
bernard
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thanos,
In my last comment, I forgot to ask how do you insert line breaks into the auto-comment, rather than have 1 long line?
e.g. I would prefer:
This issue has been resolved.
At this stage, it can either be closed or reopened.
You can request the issue to be reopened by responding to this email.
If the issue is not updated within the next 7 days, it will be automatically closed.
Once an issue is closed, it cannot be reopened.
To provide feedback on how this issue was handled by IS, please complete a survey at xxx
instead of:
This issue has been resolved. At this stage, it can either be closed or reopened. You can request the issue to be reopened by responding to this email. If the issue is not updated within the next 7 days, it will be automatically closed. Once an issue is closed, it cannot be reopened. To provide feedback on how this issue was handled by IS, please complete a survey at xxx
Thanks,
bernard
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bernard,
In you first question
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue Issue issue = issue // Get the comment, the user added in the form def originalComment = transientVars.comment as String def commentManager = ComponentAccessor.getCommentManager() def user = ComponentAccessor.getJiraAuthenticationContext().getUser() // Concat to the original comment, ours. Use \n for a new line def comment = originalComment + " This issue has been resolved.\nAt this stage, it can either be closed or reopened." commentManager.create(issue, user, comment, false)
Add this as a custom script in your Resolve Issue transition. And make sure that is after the 'Add a comment to an issue if one is entered during a transition.' step.
And then in order to send a custom email with the above comment (which should be the last comment in the issue), add in the same workflow after your previous custom post function, a send a custom email post function with the below template
Dear <% out << issue.reporter?.displayName %>,<br> The $issue has been resolved <br> <% def commentManager = com.atlassian.jira.component.ComponentAccessor.getCommentManager() def commentsList = commentManager.getComments(issue) def lastComment = "<br>" if (commentsList) lastComment = commentsList.last().getBody() // a hack to replace new lines (\n) with new lines in HTML (<br>) def styledComment = lastComment.replaceAll("\n+", "<br>") out << styledComment %> <br>Regards,<br> <% out << issue.assignee?.displayName %>
A Note: Let's say that I resolve an issue and I add a comment 'Hello world'. When I hit the Done the issue is resolved and 2 comments finally added. The first one is the 'Hello world' and the second one is the 'Hello World And the automatic message'. This is why in the email template we get only the latest comment and in order to make sure that the last comment is always the automate comment we inserted the first post function after the 'Add a comment to an issue if one is entered during a transition' post function. Please let me know if you have any further questions.
Kind regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thanos,
I have tried both your code examples (add comment and send custom email) which both work, but I have further questions.
Should I post those questions here or reach you via an alternative route?
Thanks for your support.
bernard
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bernard
I feel that we are already off-topic (the original one was about adding text to a screen) I would suggest to create a new thread for any questions you have about SR (scripts, best use cases etc). If you have a licensed version and you think that something is not working properly you can contact SR support via https://productsupport.adaptavist.com/servicedesk/customer/portal/2
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Thanos,
I will raise a new thread with my outstanding questions about Scriptrunner.
bernard
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is that possible to update the comment field (as template text) while closing a issue based on a resolution field criteria.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bernard,
Can you replace the issue with event.issue and let me know if this works for you ?
Cheers
Thanos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thanos, Sorry for my delay in replying; I'm struggling to post into this forum (1 per 24hrs and you need 3 points)! For support on scriptrunner, should I continue to post to this area, or is there an alternative method? I followed your last suggestion, but I am still seeing an error when running the code via the script console on our training server. This is the code: import com.atlassian.jira.component.ComponentAccessor def commentManager = ComponentAccessor.getCommentManager() def user = ComponentAccessor.getJiraAuthenticationContext().getUser() if (issue.subTaskObjects.any { ! it.resolutionObject }) { commentManager.create( event.issue, user, "I resolved this issue even though there were unresolved sub-tasks... slapped wrists", false) } and the resultant error: Error No such property: issue for class: Script34 groovy.lang.MissingPropertyException: No such property: issue for class: Script34 at Script34.run(Script34.groovy:6) Thanks for your support, bernard gorman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bernard, Apologies for the late response, I was off the last two days, could you please raise a request https://productsupport.adaptavist.com/servicedesk/customer/portal/2 and continue from there ? Kind regards Thanos
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.
Ideal customer email.PNGHi everybody,
We are using JIRA Service Desk 2.5.2 and JIRA 6.4.6.
We are setting up an auto-close feature for when tickets have been in the (resolved and not updated) for more than 7 days state.
Ideally, I wanted to be able to edit the resolved email notification that gets sent to customers so that it contains a message about the auto-close aspect.
I have now learnt that there are 2 notification schemes present, one in JIRA Service Desk and one in Jira.
I believe the JIRA Service Desk notification templates are not readily accessible, and would involve unpacking the application, making the changes and repacking the application.
As an alternative, I had the idea perhaps I could edit the screen (issueresolved) screen which is presented to an agent on this transition, which would be preloaded with the required auto-close text. I have installed the JIRA Toolkit plugin and have tried adding a custom message to this screen. On testing it, I can see that the text appears but within the issueresolved frame instead of the comment area.
Just wondered is there a way to make this issueresolved screen text appear in the outgoing accompanying customer email.
Attached is a screenshot of what I am trying to achieve.
Many thanks in advance.
bernard
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A screen has nothing to do with the email. The message field suggested in this question applies to screens, as it's a display field - there's nothing in the data for it on the issue. Your suggestion about putting more text in requires two changes: 1) You need a process to put your text into a proper data field 2) You need to hack the email templates to add that field Or, yes, you could throw it into the comments - you'll need a bit of code to add an additional comment on the transition (I'd use the script runner to do it) To change the customer emails, as you say, it's unpack, hack and repack JSD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Nic, Generally speaking, is it a straightforward thing to unpack, hack and repack JSD in order to change the customer emails? For the second option (throw it into the comments), how would the extra code get added to the transition. Is it through the use of a post-function? What role would script runner play in this process; generating the code only , or generating it and attaching it to the transition? bernard
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Generally, no, I don't think it is. A couple of people I know have tried it and given up, although they're not strongly technical. I've not tried it myself, just worked out that's what would be required. For the transition, you need a "post-function" that would take your extra text and add it to the comment before the emails are generated. The script-runner has a function that lets you write code that can do that directly in a post-function shell - an in-line script if you like. If you didn't do that, you'd have to write an add-on that encapsulates the code into a whole "new type of post-function available" type add-on
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic, I like the sound of the script-runner approach. Essentially, when the issueresolved screen appears for an agent (after transitioning to the resolved state), I would like the accompanying comment area (which subsequently gets email to the customer) to have the following format: 1. Normal resolution comment provided by agent 2. My first automatically-added text 3. My second automatically-added text message From your explanation, I guess this is perfectly achievable using script-runner. Had a look at https://scriptrunner.adaptavist.com/latest/jira/quickstart.html#_enhance_your_workflows but I'm not sure which area of this document I should look at (lot of detail present). I noticed (on the Atlassian web-site) that it is possible to get a trial version of script-runner, so I guess it should be possible to try this on our training server before we purchase? Thanks, bernard
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, a trial will work fine for testing. The trial licences simply expire, there's no "cut down functionality" in there. I should also make the "full disclosure" noise at this point - I work for Adaptavist, and hence with the Script Runner team. I'm also not great at scripting myself - there are far better people at Adaptavist who will be happy to lend a hand too - @Thanos Batagiannis [Adaptavist] for example... Anyway. The basic idea is that when your Agent hits "commit" on the screen that transitions the issue, it will trigger a post-function you write in SR, which will read the comment entered by the Agent, add some text, and update the "data we're changing on this issue" with the extra text. Rather than try my (shonky) coding skills on doing it from scratch, I'd check out https://scriptrunner.adaptavist.com/latest/jira/recipes/workflow/postfunctions/append-generate-comment.html This post-function creates a new comment, so you'd end up with two comments per transition, but I'm sure it's not hard to change it so it reads what the user has written and merges the two together. I'd also point out that Script Runner can send custom emails on events too - those might be helpful for some cases you have.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bernard, As Nic said, script runner can do exactly what you want (and even more). Please have a look at the documentation for the 'send custom email' built in post function https://scriptrunner.adaptavist.com/latest/jira/builtin-scripts.html#_post_functions If you have any questions or need assistance feel free to ask. Kind regards Thanos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the feedback Nic and Thanos, I am not a developer but willing to give it a go. Please excuse my questions. In our Jira Service workflow, the transition 'Resolve issue' exists going from the 'InProgress' state to the 'RESOLVED' state. Currently, when this transition is executed by one of our agents, it presents a small commend to the agent. The agent then adds their resolution comment and once they are ready, they select the 'Resolve Issue' button. The issue then changes state to RESOLVED and sends an email to the customer. The new behaviour I would like is: 1. Agent transitions ticket from InProgress to Resolved 2. Agent enters comment 1 into the comment field in the small window 3. scriptrunner adds comment 2 (my additional text) into the comment field in the small window 4. Agent selects 'Resolve Issue' button 5. Issue transitions to RESOLVED and a Jira Service Desk email is sent to the customer containing comments 1 and 2. I have installed the trial version of scriptrunner and looked at the scriptrunner documentation and your 2 suggestions (apend generate comment and send custom email). Some implementation questions (tried on our training server): 1. Given what I want to achieve, which of the 2 suggested approaches would be preferable? 2. Looking at the sample code for 'append generate comment', is the language that a script is written in 'groovy'? 3. I took the code at the link and pasted it into the scriptrunner script console which when ran produced an error message. See attached screenshot. Are there other item(s) apart from scriptrunner which I need to install before running a small code fragment like this? Thanks, bernard
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.