this is my first question here, i hope i convey it well for you to understand, i want a button to display on issue details page in Jira. when clicked it would check if (Report == Assignee) and set 'Assignee' to 'NULL' or clear that field.
If you have any other suggestions please let me know how can i implement this better or how can i do it using 'GroovyRunner' plugin...
Hi,
I dont have idea about groovy script but you can do this with java script too or writing a post function is also a better way.
If you wanna do using Java script, then here is how to do it,
Create a plugin,
write a javascript code as below,
jQuery(document).ready(function($) { JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) { checkAssignee(); }); checkAssignee(); function checkAssignee(){ AJS.$('#checkButtonId').click(function() { if($('#reporterId').val() == $('#assigneeId').val()){ $('#assigneeId').val() = ""; } }); } });
In your atlassian-plugin.xml add the following
<web-resource key="checkassignee-js" name="editissue"> <description>check assignee and reporter are same </description> <resource name="checkassignee.js" type="download" location="templates/js/checkassignee.js" /> <context>atl.general</context> </web-resource>
Add the .jar to the plugins
Hope this helps.
thanks this looks like a solid solution, can you tell be where is 'atlassian-plugin.xml' located. i can't find it. also what do you mean by 'Add the .jar to the plugins'
thanks again
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI,
If you are comfortable with groovy and you are able to solve your problem, then its fine. If you haven't done that, then you can look upon this,
We will be creating a maven plugin and how to create a maven plugin, you can see jobin kuruvilla's pdf document and once you are done with the plugin, you need to do a maven package, where it will create a .jar file under the target folder. You have to take it and upload it in jira, under manage plugins, you'll be able to see upload plugin.upload the .jar file.Once you do this. It will work.If you have any doubt check the document.
Hope this helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i'll definitly look into it, can you link the pdf.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you want to go through the book, see this link,
http://www.teamlead.ru/download/attachments/89063604/JIRA+Developments+Cookbook.pdf
or
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks i'll let you know about this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks but i can't get it to work, i created a webitem. and i want to call this jquery function you wrote.
i have created a plugin but i can't get it to work. can you please help me on this, cause i think doing this would be better as it would do it on the fly. thanks again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Javed,
Use fire bug or you can also use ctrl+shift+i (firefox,chrome..) to identify the id of the web item that you have created.Give it in the following code,
AJS.$(
'#webitemId'
).click(
function
() {
When you click on the web item it will initiate the other process.
Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can try the below groovy script and use it as the post function on Create Issue transition.
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.security.Permissions import org.apache.log4j.Logger def log = Logger.getLogger( "com.onresolve.jira.groovy.autoassign" ) def componentManager = ComponentManager.getInstance() def currentUser = componentManager.jiraAuthenticationContext?.user def permissionManager = componentManager.getPermissionManager() if (! issue.assigneeId) { if (permissionManager.hasPermission(Permissions.ASSIGNABLE_USER, issue, currentUser)) { issue.assigneeId = currentUser.name } } |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it gives me an error
javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: issue for class
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How are you running your script. Try saving the file as setassignee.groovy, and then run it by adding this post function - C:\setassignee.groovy under the Create Issue transition by putting the post function before the - 'Create Issue Originally'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks doing this right now, i'll let you know
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Glad to know that. If it works fine, then feel free to accept my answer!;)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ok i have added it into the transition but i don't think it is executed, how can i know if is executed or should it give errors or something...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check the atlassian-jira.log file located in jira-home directory . Also check if you have provided a correct path and i guess you will need to put the post function after 'Create Issue Originally' .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i edited that script given by Naren to my liking, thanks to everybody here (Naren, Nitram and Mizan)
here is the code and letting me know who to add code in transition helped me also. thanks again
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.security.Permissions import org.apache.log4j.Logger def log = Logger.getLogger("com.onresolve.jira.groovy.autoassign") def componentManager = ComponentManager.getInstance() def currentUser = componentManager.jiraAuthenticationContext?.user def permissionManager = componentManager.getPermissionManager() if (issue.reporterId == issue.assigneeId) { issue.assigneeId = '' }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Using a post function is the most appropriate solution.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You realize by clearing the Assignee field the Assigned to Me built in report won't show the work truely assigned to people? What is the value in clearing the field when what you are actually trying to indicate the issue is assigned to the reporter? By comparing the fields you're saying it is already assigned to the reporter. Remember, you'll need to maintain the mod for each future release.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks for letting me know, but if you could come up with a groovyrunner script. i have been trying this code but it is giving me error
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.security.Permissions import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.comments.CommentManager import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.util.ImportUtils import com.atlassian.jira.user.util.UserManager import com.atlassian.crowd.embedded.api.User //def componentManager = ComponentManager.getInstance() //def currentUser = componentManager.jiraAuthenticationContext?.user //def permissionManager = componentManager.getPermissionManager() def MutableIssue issue = issue def componentManager = ComponentManager.getInstance() issue = componentManager.getIssueManager().getIssueObject("JRA-1306") def userUtil= componentManager.getUserUtil() def usera = issue.reporterId def userb = issue.assigneeId if (usera == userb) { issue.setAssignee(''); }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Go through the below links. This post function will set the assignee to the current logged in user i.e., the reporter. Though this approach doesn't matches your exact requirement, but by applying this post function, the reporter will always be the assignee for the issue, which he is creating.
This approach eliminates the effort to check- if assignee is not the reporter, then make the set the Assignee field to Unassigned.
Hope it helps!
https://confluence.atlassian.com/display/JIRA/Configuring+Workflow
https://confluence.atlassian.com/display/JIRA/Configuring+Workflow
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How about adding a post function 'Assign to Current User' on Create Issue step in the workflow?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
how can i change the functionality of 'assign to current user' to assign to none.
can you provide sample code and how to run it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.