Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Restricting a Behavior to create transition

Nikhil August 5, 2019

I am trying to add a BEHAVIOR to set description with default values which i can edit before i create the ticket. And i am using the following script for it. Which work fine in bits and pieces, the not working parts comes in when i edit the ticket it erases the fields edited values and fills the default values.

so i tried a workaround by adding to the field and setting a condition to the workflow action.

Please need your help guys.

Script:-

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import groovy.transform.Field


def StoryDefaultDescValue = """Default values for story"""

def DefectDefaultDescValue =""" Default values for defect"""

def projectKey = getIssueContext().getProjectObject().getKey()
def issueTypeName = getIssueContext().getIssueType().getName()


if(getAction()?.id != 1 || issueTypeName == "Story"){
getFieldById("description").setFormValue(StoryDefaultDescValue)}

if(getAction()?.id != 1 || issueTypeName == "Defect"){
getFieldById("description").setFormValue(DefectDefaultDescValue)}

1 answer

0 votes
Roman Kersky
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 5, 2019 edited

HI. Check Screen 

 

 


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import groovy.transform.Field


if(getFieldScreen().name == "Project CREATE Ticket Screen"{

def StoryDefaultDescValue = """Default values for story"""

def DefectDefaultDescValue =""" Default values for defect"""

def projectKey = getIssueContext().getProjectObject().getKey()
def issueTypeName = getIssueContext().getIssueType().getName()


    if(issueTypeName == "Story"){
        getFieldById("description").setFormValue(StoryDefaultDescValue)}

     if( issueTypeName == "Defect"){
          getFieldById("description").setFormValue(DefectDefaultDescValue)}
}

Suggest an answer

Log in or Sign up to answer