Hi everyone,
I have a requirement where a custom field's values need to be changed depending on the Component/s field value. There will only be one value at a time for the Component/s field.
I have the options to use Script Runner/Behaviours add-ons; however kinda stuck on how to proceed.
Component A; 1,2,3
Component B; 4,5,6
Component C: 7,8,9
I'd use the cascading fields, however I do not think it allows us to use the Component/s field to base the values depending on it's values.
Thank you very much for all the ideas in advance!
Hi @Ilyas Kucukcay,
If you can explore a custom solution then your requirement can be achieved in two steps:
Hope this helps.
Regards,
Ravi Varma
+1
"Issue updated" event includes "Create issue" event or it needs to be included aswell?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are correct @[deleted].
At the first instance, Create Issue event should update the custom field value and then comes my logic for addressing Update Issue event
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ravi Varma Thanks for the reply! That's been my thinking as well; however I am struggling on what mediums to use. Do you happen to know a direct reference that would include a sample code/script to achieve this? Just curious as someone else might have done it already.
Cheers,
Ilyas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ilyas Kucukcay,
I will be sharing the psuedo code shortly. Please bear with me.
Ping me if I am not doing in the next 2 days.
Regards,
Ravi Varma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Ravi Varma Thanks again for the help, I deeply appreciate it! Any clue on how to achieve this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ilyas Kucukcay,
Please find the details as below. Hope it helps.
In pom.xml
dependency entry:
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
Import Package
<Import-Package>
org.springframework.beans.*
</Import-Package>
In atlassian-plugin.xml
<component key="SbmEventsListener" class="com.listener.JiraListener">
<description>Creates/updates xxx based on specific JIRA issue events</description>
</component>
<component-import key="eventPublisher" interface="com.atlassian.event.api.EventPublisher"/>
In JiraListener.java
private final EventPublisher eventPublisher;
public JiraListener(EventPublisher eventPublisher) {
super();
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);
log.info(IntegrationUtils.LOG_PREFIX+"Register JiraListenerForSbm to eventPublisher");
}
/**
* 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);
log.info(IntegrationUtils.LOG_PREFIX+"Unregistering JiraListenerForSbm from eventPublisher");
}
/**
* Receives any {@code IssueEvent}s sent by JIRA.
* @param issueEvent the IssueEvent passed to us
*/
@EventListener
public void onIssueEvent(IssueEvent issueEvent) {
//Put your logic
//Adding my code
Issue issue = issueEvent.getIssue();
Long eventTypeId = issueEvent.getEventTypeId();
if (eventTypeId.equals(EventType.ISSUE_CREATED_ID)) {
//set the issue's custom field value based on Component field value when issue is created
} else if (eventTypeId.equals(EventType.ISSUE_UPDATED_ID)) {
//Get the change log for component
try {
Iterator iter = issueEvent.getChangeLog().getRelated("ChildChangeItem").iterator();
while (iter.hasNext()) {
GenericValue changeItem = (GenericValue) iter.next();
String issueProperty = (String) changeItem.get("field");
String issuePropertyOldValue = (String) changeItem.get("oldstring");
String issuePropertyNewValue = (String) changeItem.get("newstring");
System.out.println(IntegrationUtils.LOG_PREFIX+"\t'"+issueProperty + "' changed from '"+issuePropertyOldValue+"' to '"+issuePropertyNewValue + "'");
//If changed issue property is Component/s then update the issue's custom field value
}
} catch (GenericEntityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
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.