How to append new selected list value to existing multi line scripted field Edited

Hi, below is my use case.

  • I have a Custom field defined with check boxes
  • When user selects the check boxes, am adding it to a Scripted field and keep appending to the Multi line scripted field as they select to track all the selction

Below is the script i have

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager

def customFieldManager = ComponentAccessor.customFieldManager
CustomField customFieldDE = customFieldManager.getCustomFieldObjectByName("RPR DE Return Reason")
CustomField customFieldPM = customFieldManager.getCustomFieldObjectByName("RPR PM Return Reason")


def customFieldtrail = customFieldManager.getCustomFieldObjectByName("RPR Return Err Code Trail")
def customFieldtrailval = getCustomFieldValue(customFieldtrail)

//System.out.println("Custom field value: " + customFieldtrailval)

StringBuilder stringBuilder = new StringBuilder()
stringBuilder.append(customFieldtrailval)

((List<Option>) issue.getCustomFieldValue(customFieldDE)).each {
stringBuilder.append(it.getValue()).append(", ")
}

((List<Option>) issue.getCustomFieldValue(customFieldPM)).each {
stringBuilder.append(it.getValue()).append(", ")
}

return stringBuilder.toString()

The issue i have is on the bold line. it is lways returning Null.

 

below is what i get

nullD1-1(Incorrect Revenue),

Kindly advise, if there are better options to handle this .

 

Thanks in advance

 

 

 

 

1 answer

1 accepted

This widget could not be displayed.
Jenna Davis Community Champion Jul 17, 2017

Hello,

I think you may be better off using a listener for this purpose, then putting the result that the listener calculates into a custom field if you need it displayed.

You should be able to use similar code, with a few modifictions to access fields and such. 

You can read more about listeners here.

Let me know if you need any help setting this up!

Jenna

Thank you Jenna, will try and keep this thread updated

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

139 views 2 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you