Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass multiple parameters to jira custom service?

Jonnada Kiran
Contributor
December 12, 2018

Hi All,

I am writing an add on. I wrote a custom service which should take two parameters from the UI and print it.

But It was taking the first property and ignoring the second property.

Service.class

package com.kworks.timeinstatus.services;
import com.atlassian.configurable.ObjectConfiguration;
import com.atlassian.configurable.ObjectConfigurationException;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.service.AbstractService;
import com.opensymphony.module.propertyset.PropertySet;

import java.io.*;
import com.atlassian.mail.Email;
import com.atlassian.mail.server.MailServerManager;
import com.atlassian.mail.server.SMTPMailServer;
import com.atlassian.jira.component.ComponentAccessor;
import javax.mail.internet.*;
import javax.mail.*;
import javax.activation.*;
import javax.mail.Multipart;
import javax.mail.internet.MimeMultipart;
import java.nio.file.Files;
import java.nio.file.Paths;


public class TimeInStatusService extends AbstractService {
public static final String TUTORIAL = "Tutorial";
public static final String TUTORIAL1 = "Tutorial";
private String jql;
private String subscriber;
@Override
public void init(PropertySet props) throws ObjectConfigurationException {
super.init(props);

if (hasProperty(TUTORIAL)) {
jql = getProperty(TUTORIAL);
} else {
jql = null;
}
if (hasProperty(TUTORIAL1)) {
subscriber = getProperty(TUTORIAL1);
} else {
subscriber = null;
}
}

@Override
public ObjectConfiguration getObjectConfiguration() throws ObjectConfigurationException {
return getObjectConfiguration("MYNEWSERVICE", "com/kworks/services/mytimeinstatusservice.xml", null);
}

@Override
public void run(){
String result = sendmail();

System.out.println("JQL is: "+jql+" Application User is: "+subscriber);
}

@Override
public void destroy() {
System.out.println("Let me do this before destory!");
super.destroy();
}

}

Service.xml

 

<someservice id="jtricksserviceid">
<description>My New Service</description>
<properties>
<property>
<key>Tutorial</key>
<name>JQL</name>
<type>string</type>
</property>
<property>
<key>Tutorial1</key>
<name>Subscriber</name>
<type>string</type>
</property>
</properties>
</someservice>

 

Input:

Capture.PNG

Expected Result:
JQL is: Test Application User is: Kiran

Actual Result:
JQL is: Test Application User is: Test

Please Help me.

Thanks,
Kiran.

1 answer

0 votes
Bastian Stehmann
Community Champion
December 12, 2018

Hi @Jonnada Kiran,

I'm sorry I don't know how to help you, but I think you will find more help in the developer community https://community.developer.atlassian.com

Suggest an answer

Log in or Sign up to answer