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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Sync between structure and issues

Hey community,
I've written a listener that changes the value of a certain custom field.
The problem is that the field does get updated in the relevant issue but on Structure it doesn't (only if I manually update some field in that issue via Structure and then it updates the data). In addition, I've tried to add re indexing to the listener script and the logs shows everything works fine, also when I export the issues the data is updated which means the changes are actually written to the database.
In conclusion, I think the problem is in the structure "behavior".

Thanks in advance.

1 answer

Hello @Yuval Maron 

David from ALM Works here.

Structure relies on Jira's EventManager updates to refresh data.
Please check if the updates you expect to see in Structure are being displayed in the Issue's History Tab.
You should be able to see a "made changes" entry if you open the Issue and look at the History tab under the Activity section of the page.

If there's no update on the Issue History, our suggestion is to change the script to use either one of these options:

  • initiate issue event manually using IssueEventManager
  • use IssueManager.updateIssue() with corresponding event dispatch option to update the field.

If you do see the events in the issue history, it may be best to work directly with our support team. You can initiate a ticket by emailing support@almworks.com or through our portal support.almworks.com.

Please let me know if this helps. I look forward to your reply!

Best Regards,
David Niro
www.almworks.com

@David Niro_ALM Works 
Thank you for your help!
I don't see the relevant changes in the activity history, 
The second option didn't work for me, you have an example of the first one and how to use it?

Hello Yuval,

You are very welcome!

I can share an example of how each option would look.

Option 1:

import 
com.atlassian.jira.event.issue.IssueEventDispatcher

def 
CUSTOM_SCRIPTRUNNER_UPDATE_EVENT = 10000 // TODO: define event type id here
IssueEventDispatcher.dispatchEvent(CUSTOM_SCRIPTRUNNER_UPDATE_EVENT, issue, null, false);

Option 2:

issue.setCustomFieldValue(customField, customFieldNewValue)

ComponentAccessor.getIssueManager().updateIssue(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), (MutableIssue)currentIssue, EventDispatchOption.ISSUE_UPDATED, true);

Please let me know if this helps!  I look forward to your response!!

Best Regards,
David Niro
www.almworks.com

@David Niro_ALM Works 

Thanks, I'll continue Yuval's work on this issue :) 

 

Is 1000 the ID of the task update event?

If not, how can I find this ID?

 

 

Best Regards,

Dorin

Hello @dorin gez !

1000 is an example.  You will need to create a custom event and then reference it.  Here are the steps:

1) Add a new custom event using *Administration* *>* *System >* *Advanced > Events,* add a new event using template - *Generic Event*.

2) Take the *event type id* that can be found in the browser address bar if click the ‘Edit’ link for the new event 

3) Update the scripted field  - add triggering this new custom Jira event on the value calculation. The *_event_type_id_* should be taken from the previous step.

Please let me know if it helps!

Best Regards,
David Niro
www.almworks.com

Hell @David Niro_ALM Works !

Thank you so much for the detailed tutorial it really helped me understand your solution.
I created an event and linked it as described in your explanation and the update is still not done properly  - nothing changes inside the structure..
Code:

import com.atlassian.jira.event.issue.IssueEventDispatcher



def CUSTOM_SCRIPTRUNNER_UPDATE_EVENT = 10100 // My Generic Event
IssueEventDispatcher.dispatchEvent(CUSTOM_SCRIPTRUNNER_UPDATE_EVENT, issue, null, false);


I would be happy for your help to correct my code

Thank you,
Dorin

Hello @dorin gez ,

You are very welcome!  To assist further, we would need to review the entire script.

Would you please initiate a support request with us?  You can email support@almworks.com or create a directly from our portal support.almworks.com.

I look forward to continuing our conversation!

Best Regards,
David Niro
www.almworks.com

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

⏰ Day in the life of a Jira Admin!

Hello Community! We thoroughly enjoyed this just-for-fun conversation in the Jira Admin Group about what it's like to be a Jira Admin. For #JiraJuly, our talented designers created these graphics t...

871 views 2 22
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you