Forums

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

How to add default value (Tested:) before summary copied from parent to sub:task on create screen

siva
Contributor
January 17, 2022

Hello,

Here I used the script using script runner behaviour that copies summary field from parent to sub:task and this script working perfectly but here i need to add default value (Tested:) before the summary in sub:task and copied the summary from parent.

For example 

Parent summary: Good to know

Sub:task summary should be Tested: Good to know

please suggest me where to add script in the below script  

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.web.util.OutlookDate
import com.atlassian.jira.web.util.OutlookDateManager
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript

import java.sql.Timestamp

import static com.atlassian.jira.issue.IssueFieldConstants.*

@BaseScript FieldBehaviours fieldBehaviours

FormField field = getFieldById(getFieldChanged())
FormField parent = getFieldById("parentIssueId")
Long parentIssueId = parent.getFormValue() as Long


if (!parentIssueId || field.getFormValue()) {
// this is not a subtask, or the field already has data
return
}

def issueManager = ComponentAccessor.getIssueManager()
def parentIssue = issueManager.getIssueObject(parentIssueId)
def customFieldManager = ComponentAccessor.getCustomFieldManager()

// REMOVE OR MODIFY THE SETTING OF THESE FIELDS AS NECESSARY
getFieldById(SUMMARY).setFormValue(parentIssue.summary)

1 answer

1 accepted

0 votes
Answer accepted
siva
Contributor
January 18, 2022

I got solution for this just need to add the default text on this line of your script:

getFieldById(SUMMARY).setFormValue('Tested: ' + parentIssue.summary)

may be this will helps someone else.

 

Thanks,

Siva

Suggest an answer

Log in or Sign up to answer