Forums

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

Append a string to a custom field using workflow post function

sadhana_chittibabu January 22, 2024

Hi Team,

I have a requirement to append a string with the existing value of a custom field when issue transitioning to a specific status.

Is there any way to acheive this using workflow post function.

Thanks,

Sadhana

3 answers

0 votes
Manne Kjærby - ProProces
Atlassian Partner
January 23, 2024

Hi Sadhana

I believe the easiest way would be an Automation rule, as @John Funk suggest.

Aswin suggestion looks like code for the server version and would need a additional add on to execute, so I don't think it's applicable for your case.

0 votes
John Funk
Community Champion
January 22, 2024

Hi Sadhana,

Have you thought about doing that with an Automation Rule? 

0 votes
Aswin Raj D
Community Champion
January 22, 2024

Hi @sadhana_chittibabu ,

Yes, you can achieve this using a workflow post function in Jira. Workflow post functions are executed after a workflow transition is triggered. To append a string to the existing value of a custom field, you can use a custom script post function. The script might look something like this.

 

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issue = issue
def customFieldId = "customfield_XXXXX" // Replace XXXXX with the actual ID of your custom field
def existingValue = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject(customFieldId))

// Append your desired string
def appendString = "AppendedText"
def newValue = existingValue + appendString

// Update the custom field with the new value
issue.setCustomFieldValue(customFieldManager.getCustomFieldObject(customFieldId), newValue)
Make sure to replace "customfield_XXXXX" with the actual ID of your custom field and adjust the appendString variable accordingly.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events