0

I have a requirement to automatically populate a custom field during a particular workflow transition. This field is called "Owner" and should be populated with the name of the asignee.

I am new to scripting post functions, so as a first step, I tried the following code to attempt to populate that field with a test string. The workflow transition works, I see no errors, but the field remains empty.

import com.atlassian.jira.bc.issue.search.SearchService;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.web.bean.PagerFilter;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.CustomFieldManager;

ComponentManager componentManager = ComponentManager.getInstance();
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager();
CustomField cfOwner = customFieldManager.getCustomFieldObjectByName("Owner"); IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
cfOwner.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customFieldTarget), "Test"), changeHolder);

I would appreciate assistance to determine what I am doing wrong.

1 Answer 1

1

I think you can use in built post functions to achieve this.go to edit your workflow and select your transition need to be configure then click on post functions then navigate to add post function.

enter image description here

then select post function shown as the image then in next screen you can select your custom field and you can set the value as you need. enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.