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

How to Create Worklog automatically via plugin?

Hi

I've written a listener plugin that amongst other things, automatically updates the worklog based on the user pressing start progress & stop progress.

The worklog updates at the bottom of the screen, but the logged work shown on the right of the screen (plus the remaining estimate) does not update.

it is calling createAndAutoAdjustRemainingEstimate

Is there anything I've missed? It works fine except it doesnt appear to update the estimate

ComponentManager cm = ComponentManager.getInstance(); 

IssueIndexManager indexManager = cm.getIndexManager(); 

 

JiraAuthenticationContext jac = cm.getJiraAuthenticationContext();

User user = jac.getUser();

//JiraServiceContext jsc = new JiraWebActionSupport().getJiraServiceContext();

JiraServiceContext jsc = new JiraServiceContextImpl(user);

WorklogService wls = (WorklogService) ComponentManager.getComponentInstanceOfType(WorklogService.class);

JiraServiceContext context = new JiraServiceContextImpl( user );

 

       String timeSpent = dur + "m";

       startFieldText.getCustomFieldType().updateValue(startFieldText,issueEvent.getIssue(),timeSpent);

       WorklogNewEstimateInputParameters params = createParams( issue, timeSpent, stDate );

 

       WorklogResult result = wls.validateCreate( context, params );

       wls.createAndAutoAdjustRemainingEstimate( context, result, true );

 

   try { 

indexManager.reIndex(issueGV2); 

} catch (IndexException e) { 

throw new WorkflowException(e); 

} 

 

private WorklogNewEstimateInputParameters createParams( MutableIssue issue, String timeSpent, Date StartDate ) {

       return WorklogInputParametersImpl

               .issue( issue )

               .startDate( StartDate )

               .timeSpent( timeSpent )

               .comment( "Autologged " + timeSpent + "." )

               .buildNewEstimate();

   }

2 answers

screengrab

Is this working for you now? I am in need of the same thing.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted 30m ago in Jira

Upcoming Enterprise releases targeting Q3 2019: Jira Software 8.5 & Jira Service Desk 4.5

Since launching the Jira Software 8.0 and Jira Service Desk 4.0 platform releases in February, many of you have been asking when the next Enterprise release will be so you can take advantage of the m...

148 views 0 2
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you