Hi @Normann P_ Nielsen _Netic_
Your approach will not work because it needs the java.sql.Date and not the java.util.Date.
Below is a sample working code for your reference:-
import com.adaptavist.hapi.jira.issues.Issues
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.index.IssueIndexingParams
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import java.sql.Date
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)
def customFieldManager = ComponentAccessor.customFieldManager
def issue = Issues.getByKey('MOCK-3') as MutableIssue
def customField = customFieldManager.getCustomFieldObjectsByName('Date Time Sample').first()
customField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customField), new Date(System.currentTimeMillis())), new DefaultIssueChangeHolder())
issueIndexingService.reIndex(issue, IssueIndexingParams.INDEX_ISSUE_ONLY)
Please note that the sample working code above is not 100% exact to your environment. Hence, you must make the required modification.
The code has been tested on the ScriptRunner console.
Below is a screenshot of the result for your reference:-
In the screenshot above, you can see that the Date Time Sample field is updated but no history is added.
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
AS posted yesterday, I found the solution in https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Java-type-java-util-Date-not-currently-supported-Sorry/qaq-p/592502
to use .toTimeStamp() instead of .getTime()
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.