Forums

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

ScriptRunner Post-function add 1 month to date field and update date field

Chris Ghazanchian
Contributor
March 24, 2018

I would like to add 1 month to a custom date field (Next Cycle Date) and then update that date field upon a workflow transition (post-function).

I have the current script but it's not doing anything, not sure what I am doing wrong.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.UpdateIssueRequest
import java.text.SimpleDateFormat

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()

SimpleDateFormat dateFormatter = new SimpleDateFormat("dd/MMM/yy");
java.sql.Timestamp nextCycleDate = (java.sql.Timestamp)issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_10603")) //get current "next cycle date"

nextCycleDate.setMonth(nextCycleDate.getMonth() + 1) //add 1 month to current cycle date to get next cycle date

issue.setCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_10603"), nextCycleDate) //update next cycle date

 

2 answers

0 votes
Bruna Griebeler
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 Champions.
June 18, 2014

Hi guys,

If you have duplicated users, what happens if you put Crowd Directory in the first place in the User Diretcory order?

You could test it with a single user.

Let's say that you have john on both Jira and Crowd.

1) Put Crowd at the top on the Directories list;

2) Disable the user john (from internal);

3) Check if he's still able to login as expected authenticating on Crowd;

Here is the a documentation about migrating users between directories that might help:

https://confluence.atlassian.com/display/JIRA/Migrating+Users+between+User+Directories#MigratingUsersbetweenUserDirectories-MigratingUsersbyChangingtheDirectoryOrder

0 votes
Joan Roth
June 18, 2014

I have a similar problem. We have Confluence and JIRA users imported using an active directory connection, but we have several users who were manually added. These duplicates have history. Is there a quick way to move history from one user to another prior to deleting the duplicate user?

jamie rosenfield
August 9, 2016

i'm curious how to answer this as well?!

Suggest an answer

Log in or Sign up to answer