Hi,
I would like to update a Message field on the view screen of an issue. When the issue transition from one status to another. I would like to use HTML and add information from some of the issues fields.
I would be grateful of any help as I have spent a lot time trying get this working.
We have the following add-on
Script runner, JMWE, CF++
I have tried using
- using a standard jira comments field with wiki formatting
- JIRA message field
- Script runner message field
But can't seem to get them to update during the transition?
I not great a script, if you any examples that would be great.
Many Thanks
Kevin
Hi Kevin,
We have a sample code for setting content of Message++ field using ScriptRunner in our wiki. You can email to me if you need further information.
Hi @Kevin Seery
You can create a Text Field (read only) and use the following code in the ScriptRunner's Script Post-Function on your transition.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
//get the value of Message Field
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObjectsByName("Message Field")
def cFieldValue = issue.getCustomFieldValue(cField[0])
//Prepare the message with system field or custom message
def message = "*Issue status*: " +
issue.getStatus().name + "\n" +
"*This is a message*"
//update the value
def changeHolder = new DefaultIssueChangeHolder()
cField[0].updateValue(null, issue, new ModifiedValue(cFieldValue, message),changeHolder)
In the code as you can see I am retrieving issue status and also custom field value. You can retrieve any system field or custom field value and prepare your message which you can then update in the message field that you want to display on the issue
For HTML, it is a bit tricky as I am using wiki style renderer which I suggest you try if you just want to try basic editing.
I hope it helps.
Ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ravi,
Thanks for replying, I was hope to use HTML so I could get the format I wanted.
Many Thanks
Kevin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ravi, your solution to update a read-only field is perfect for my needs. Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Good to know.
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.