Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Why my customField value was set to null when I click "Resovle Issue" button?

Deleted user May 16, 2012

It's a GenericTextCFType customField I wrote to achieve a simple goal, that let the customField's value added 2 when I click the "Start Progress" OR "Stop Progress" OR "Resovle Issue" button. However, it's too strange that customField's value added right when clicking "Start Progress" AND "Stop Progress", but the value is set to null when I clicking "Resovle Issue".

Is there anybody know the reason?

Additional, I use "issue.getCustomFieldValue(customField)" to fetch the value every time

4 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Deleted user May 16, 2012

this is my code of listener to do what add 2 in my customField value when issue resolved.

Its value should be 2,4,6,8.... But now, it's 2 no matter how many times I click "Resolve Issue".

And, from the data of my debug, the method issue.getCustomFieldValue(customField) will always return null .

Why could this situation occur?

0 votes
Deleted user May 16, 2012
public void workflowEvent(final IssueEvent event){
		final Long eventTypeId = event.getEventTypeId();
getIssuePreviousStatus(event);		if(eventTypeId.equals(EventType.ISSUE_RESOLVED_ID)){
			CustomField customField = customFieldManager.
			getCustomFieldObjectByName(CUSTOM_FIELD_NAME);
	String counter =(String) issue.getCustomFieldValue(customField);
	long numCounter = 0L;
	if(counter != null){
		 numCounter = Long.valueOf(counter);
	}
	else
	{
		 numCounter = 0L;
	}
	
	if(customField!=null && issue !=null)
	{
		FieldLayoutManager fieldLayoutManager = ComponentAccessor.getFieldLayoutManager();
		FieldLayoutItem fieldLayoutItem = fieldLayoutManager.getFieldLayout(issue).getFieldLayoutItem(customField);
		String modifiedValue =String.valueOf(numCounter+2);
		customField.updateValue(fieldLayoutItem, issue, new ModifiedValue(issue.getCustomFieldValue(customField),modifiedValue), new DefaultIssueChangeHolder());
	}
	
		}
	}

0 votes
Deleted user May 16, 2012
public void workflowEvent(final IssueEvent event){
		final Long eventTypeId = event.getEventTypeId();
		Issue issue = event.getIssue();
if(eventTypeId.equals(EventType.ISSUE_RESOLVED_ID)){
			CustomField customField = customFieldManager.
			getCustomFieldObjectByName(CUSTOM_FIELD_NAME);
	String counter =(String) issue.getCustomFieldValue(customField);
	long numCounter = 0L;
	if(counter != null){
		 numCounter = Long.valueOf(counter);
	}
	else
	{
		 numCounter = 0L;
	}
if(customField!=null && issue !=null)
	{
		FieldLayoutManager fieldLayoutManager = ComponentAccessor.getFieldLayoutManager();
		FieldLayoutItem fieldLayoutItem = fieldLayoutManager.getFieldLayout(issue).getFieldLayoutItem(customField);
		String modifiedValue =String.valueOf(numCounter+2);
		customField.updateValue(fieldLayoutItem, issue, new ModifiedValue(issue.getCustomFieldValue(customField),modifiedValue), new DefaultIssueChangeHolder());
	}}

0 votes
Deleted user May 16, 2012

public void workflowEvent(final IssueEvent event){

final Long eventTypeId = event.getEventTypeId();

Issue issue = event.getIssue();

if(eventTypeId.equals(EventType.ISSUE_RESOLVED_ID)){

CustomField customField = customFieldManager.

getCustomFieldObjectByName(CUSTOM_FIELD_NAME);

String counter =(String) issue.getCustomFieldValue(customField);

long numCounter = 0L;

if(counter != null){

numCounter = Long.valueOf(counter);

}

else{

numCounter = 0L;

}

if(customField!=null && issue !=null)

{

FieldLayoutManager fieldLayoutManager = ComponentAccessor.getFieldLayoutManager();

FieldLayoutItem fieldLayoutItem = fieldLayoutManager.getFieldLayout(issue).getFieldLayoutItem(customField);

String modifiedValue =String.valueOf(numCounter+2);

customField.updateValue(fieldLayoutItem, issue, new ModifiedValue(issue.getCustomFieldValue(customField),modifiedValue), new DefaultIssueChangeHolder());

}

}

}

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events