Hi all,
I want to preload a template for my users to follow when creating certain issues. We use an issue type for users to reach out to management for publishing access, and ideally, we'd like to provide a template for them to fill out whenever they select the component "Open Source" and set/select the label "Publish_Blog".
This is what I have so far set as the initialiser for publish access issue types in our project:
import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.COMPONENTS
import static com.atlassian.jira.issue.IssueFieldConstants.LABELS
def desc = getFieldById("description")
def summary = getFieldById("summary")
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
def components = projectComponentManager.findAllForProject(issueContext.projectObject.id)
def defaultValue = """1. Where can we find the text you wish to publish? Provide a Google Doc or repo link. See examples at _______.com
2. What meta tags should be added to the post?
3. Who is the author and owning team? Who should this post be attributed to?
4. What is the business value to Avg Jo's for publishing this post?
5. Does your manager and project architect that this should be published, including review for confidential internal information?
6. What is the name of your L2 for approval? Please add to Reviewer field.
7. Should this be distributed on Avg Jo's social channels?
8. Did someone from your group's comms team review and edit the content?
9. Is there an embargo date (don't publish before) or deadline (must publish by)? Please set Due Date to desired publish date""".replaceAll(/ /, '')
def defaultValue2 = """Request to publish public engineering blog post for <project or team name>???""".replaceAll(/ /, '')
if ((getFieldById(LABELS)) == "Publish_Blog" && getFieldById(COMPONENTS) == "Open Source" && getActionName() in ["Create Issue", "Create"]) {
desc.setFormValue(defaultValue)
summary.setFormValue(defaultValue2)
}
This unfortunately doesn’t work because when I navigate to the Create Issue form and set the component and label fields as defined, summary and description are still null.
Any help would be highly appreciated .
An initialiser in a behaviour only runs when the form is initially loaded. It does not "react" to values changing in the form. For that you will need to add fields you want the behaviour to react to (such as labels) and add server side script.
You would need the getValue() method to return the value for the current issue.
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 response @Raynard Rhodes .
I updated the script as shown:
import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.COMPONENTS
import static com.atlassian.jira.issue.IssueFieldConstants.LABELS
def desc = getFieldById("description")
def summary = getFieldById("summary")
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
def components = projectComponentManager.findAllForProject(issueContext.projectObject.id)
def compVal = getFieldById(COMPONENTS).getValue()
def labelVal = getFieldById(LABELS).getValue()
def defaultValue = """1. Where can we find the text you wish to publish? Provide a Google Doc or repo link. See examples at _______.com
2. What meta tags should be added to the post?
3. Who is the author and owning team? Who should this post be attributed to?
4. What is the business value to Avg Jo's for publishing this post?
5. Does your manager and project architect that this should be published, including review for confidential internal information?
6. What is the name of your L2 for approval? Please add to Reviewer field.
7. Should this be distributed on Avg Jo's social channels?
8. Did someone from your group's comms team review and edit the content?
9. Is there an embargo date (don't publish before) or deadline (must publish by)? Please set Due Date to desired publish date""".replaceAll(/ /, '')
def defaultValue2 = """Request to publish public engineering blog post for <project or team name>???""".replaceAll(/ /, '')
if (labelVal.toString().contains("Publish_Blog") && compVal.toString().contains("Open Source") && getActionName() in ["Create Issue", "Create"]) {
desc.setFormValue(defaultValue)
summary.setFormValue(defaultValue2)
}
No luck, unfortunately :(
I do have this set as the initialiser for this behaviour though. Could that be the issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What happens if you create an issue with an empty description field using the component?
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.