Is it possible to do field level scripting in JIRA?

Amrita Saha September 30, 2013

whenever an user enters values into custom field ,we have to update the data to another one custom field,with user name and value entered in the first custom field.is it possible in jira to do scripting at field level.

3 answers

1 vote
Amrita Saha September 30, 2013

Thank you.

could you please explain in detail about this since Im new to jira dev.

Bharadwaj Jannu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 30, 2013
public class YourListenerClass extends AbstractIssueEventListener implements InitializingBean,DisposableBean
{
	private final EventPublisher eventPublisher;
	
	public YourListenerClass(EventPublisher eventPublisher)
	{
		this.eventPublisher=eventPublisher;
	
	}
	 /*
     * Called when the plugin has been enabled.
     * @throws Exception
     */
	@Override
    public void afterPropertiesSet() throws Exception 
    {
        // register ourselves with the EventPublisher
        eventPublisher.register(this);
        System.out.println("Installed or Enabled");
    }
  
    /*
     * Called when the plugin is being disabled or removed.
     * @throws Exception
     */
	@Override
    public void destroy() throws Exception 
    {
        // unregister ourselves with the EventPublisher
        eventPublisher.unregister(this);
        System.out.println("Disabled or Uninstalled");
    }
	
	
	@EventListener
    public void onIssueEvent(IssueEvent issueEvent)
    {
		Long eventTypeId = issueEvent.getEventTypeId();
        
    	if(eventTypeId.equals(EventType.ISSUE_UPDATED_ID)||eventTypeId.equals(EventType.ISSUE_CREATED_ID))
    	{
             ...
        }
    }
}

the above is the template for your listener

Bharadwaj Jannu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 30, 2013

I suggest Listener is the good option. You need to write your own plugin.

#1) You get the sdk. This document help you.

#2) Now practise helloworld plugin. Refer

https://developer.atlassian.com/display/DOCS/Create+a+HelloWorld+Plugin+Project

#3) Following the below link

https://developer.atlassian.com/display/JIRADEV/Writing+JIRA+Event+Listeners+with+the+atlassian-event+Library

you develop your listener

<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
    <plugin-info>
        <description>${project.description}</description>
        <version>${project.version}</version>
        <vendor name="${project.organization.name}" url="${project.organization.url}" />
        <param name="plugin-icon">images/pluginIcon.png</param>
        <param name="plugin-logo">images/pluginLogo.png</param>
		
    </plugin-info>
	
	<component key="<SomeListener_Key>" class="<your Listener class relative path>">
		<description>Some description.</description>
	</component>
</atlassian-plugin>

probably the above code should present in your atlassian-plugin.xml


0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 30, 2013

Yes... write your own javascript hooks, or behaviours plugin, or (I believe it's called) Live Fields in JJUPIN.

And a few other plugins.

For rolling your own javascript, there are lots of questions about that here.

0 votes
Bharadwaj Jannu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 30, 2013

Yes it is possible by using a workflow postfunction or listeners to ISSUE_CREATED or ISSUE_UPDATED events.(needed Java Coding)

Otherwise you can place some javascript to read the values from the cusfomfields. I'm not much familier with Jira Java Script. You can go through the link which give some idea.

Bharadwaj Jannu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 30, 2013

Suggest an answer

Log in or Sign up to answer