I have both JMCF and Scriptrunner so I could go either way with a solution here, I have tried some of the solutions provided in other community articles but no luck getting it to click yet.
So I have field called "Date of Receipt"
I want to be able to create a due date based on that date + 30 days. So when the user creates the issue they will enter the date of receipt in a custom date field, i want it to display in separate custom field called Issue Due Date the date in the date of receipt field plus 30 days.
You can use script runner- add new post function > custom script, and add this code:
import java.sql.Timestamp;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.type.EventDispatchOption
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def issueManager = ComponentAccessor.getIssueManager()
def dateCustomField = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject(10504 as long))
if(dateCustomField != null){
//if you want to set the system field Due Date
issue.setDueDate( (Timestamp) dateCustomField + 30);
//if you want to set a different custom field of type Date Picker
def customFieldToSet = customFieldManager.getCustomFieldObject(10500 as long)
issue.setCustomFieldValue(customFieldToSet, (Timestamp) dateCustomField + 30);
issueManager.updateIssue(currentUser, issue, EventDispatchOption.ISSUE_UPDATED, true)
}
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.
Yes, you can use this-
getCustomFieldObjectByName("field name")
instead of
getCustomFieldObject(10500 as long)
If this work for you please accept the answer :)
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.