We have a business requirement where we have to update a custom field with the value of a profield when the issue is being created. For this we have applied a post function script which runs on create issue transition in the workflow. But the script startup failed and unable to resolve classes error is coming in the logs.
In the script profield data is coming correctly.
Can you please suggest the solution to resolve the issue and any modification if required.
This is the error log file
import com.atlassian.jira.component.ComponentAccessor import com.deiser.jira.profields.api.field.FieldService import org.apache.log4j.Logger import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.util.IssueChangeHolder import com.atlassian.jira.issue.Issue import com.atlassian.event.api.EventListener; import com.atlassian.event.api.EventPublisher; import com.atlassian.jira.event.issue.IssueEvent; public class UpdateStudioJobsListener { //Register the Event Listener Class with the EventPublisher public UpdateStudioJobsListener(EventPublisher eventPublisher) { eventPublisher.register(this); } @EventListener public void onIssueEvent(IssueEvent issueEvent) { def FIELD_ID = 7; def fieldService = ComponentAccessor.getOSGiComponentInstanceOfType(FieldService.class); def logger = Logger.getLogger(getClass()); def profieldsField = fieldService.get(FIELD_ID); def profieldsFieldValue = profieldsField.getValueInProject(issue.projectObject); println("first"+profieldsFieldValue); logger.warn(profieldsFieldValue); def ComponentManager componentManager = ComponentManager.getInstance(); def customFieldManager = ComponentManager.getCustomFieldManager(); def customFieldAccountName= customFieldManager.getCustomFieldObject('customfield_21900'); //write your own custom field id here def customFieldAccountNameValue = issue.getCustomFieldValue(customFieldAccountName); println("first second"+customFieldAccountNameValue) if(profieldsFieldValue!=null){ Issue issue = issueEvent.getIssue(); IssueChangeHolder changeHolder = new DefaultIssueChangeHolder(); customFieldAccountName.updateValue(null,issue,new ModifiedValue(customFieldAccountNameValue,profieldsFieldValue),changeHolder); println("second"+customFieldAccountNameValue) //logger.warn(customFieldAccountNameValue ); } } }
You have a bunch of missing imports, eg ModifiedValue
And, this is not going to work:
import
com.deiser.jira.profields.api.field.FieldService
You need to use @WithPlugin annotation to allow the script to access the classloader of the profields plugin.
See this page: https://jamieechlin.atlassian.net/wiki/display/GRV/Scripting+Other+Plugins
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.