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

Jira plugin : How to add a condition in my custom field to limit the bulk change ?

christophe December 1, 2015

When we do a bulk change (change several issues simultaneously), some fields can not be changed if the issues come from several different projects.

I need to have the same behevior for my custom field (plugin). How to do that?

 

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
z December 1, 2015

In your custom field code, override the availableForBulkEdit function to return a string and your custom field will be excluded from bulk edit. If you return empty string or null, then the field will be available for bulk edit.

public class YourCustomCFType extends TextCFType
{
	...
 
	@Override
	public String availableForBulkEdit(BulkEditBean bulkEditBean) 
	{
    	return "bulk.edit.unavailable";
	}
}

See also: https://docs.atlassian.com/jira/latest/com/atlassian/jira/issue/customfields/impl/AbstractCustomFieldType.html#availableForBulkEdit-com.atlassian.jira.web.bean.BulkEditBean-

0 votes
christophe December 1, 2015

Thanks a lot Tan Zhi Rong. your solution is the good one!

I 've searched in source of JIRA to find the different values :

  • return "bulk.edit.unavailable.multipleprojects"; 
  • return "bulk.edit.unavailable.noversions";
  • return "bulk.edit.unavailable.hidden";
  • return "bulk.edit.unavailable.permission";
  • return "bulk.edit.unavailable.different.renderers";
  • return "bulk.edit.unavailable.nocomponents";
  • return "bulk.edit.incompatible.customfields";
  • ...

And the solution is to add in my custom type

@Override
public String availableForBulkEdit(BulkEditBean bulkEditBean) {
return "bulk.edit.unavailable.multipleprojects";
}

z December 1, 2015

bulk.edit.unavailable.multipleprojects = {0}NOTE{1}: This operation can be performed only on issues from ONE project. If that's the message you want.. For your case: "some fields can not be changed if the issues come from several different projects" I think you will need to add extra check conditions for the project and return bulk.edit.unavailable.multipleprojects or null correspondingly: Collection<Project> projects = bulkEditBean.getProjectObjects(); But you might have problem if the bulk edit contains a mix of issues that comes from projects that can and cannot edit...

christophe December 3, 2015

You are right. What have I written is not enought. The good solution is: @Override public String availableForBulkEdit(BulkEditBean bulkEditBean) { if (bulkEditBean.isMultipleProjects()) { // Let the user know that selected issues belong to more than one project so the action is not available return "bulk.edit.unavailable.multipleprojects"; } return null; } and it is working well. If found this solution here: atlassian-jira-6.4.9-source\jira-project\jira-components\jira-core\src\main\java\com\atlassian\jira\issue\customfields\impl\VersionCFType.java

0 votes
Chris Stamp December 1, 2015

Check  this out https://marketplace.atlassian.com/plugins/com.onresolve.jira.groovy.groovyrunner/server/overview (sorry abbreviated links aren't working for some reason). It is much faster in terms  of deploying customizable solutions for workflows, custom fields etc instead of full blown plugins. In  regards to "limiting" the bulk behavior  you must have a  defined standard of value/values  that would  be part of a condition in your code to determine  what changes and what doesn't.

What type of custom field is this?

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