Forums

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

How to change custom field type(Date time picker --->Date)??

Raju Anumula June 5, 2018

Hi Team

I have a custom field with Date and Time picker but now realized fields should be only "Date" and do not need time also to be captured.

Thanks in advance.

2 answers

1 accepted

1 vote
Answer accepted
Alexey Matveev
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 Leaders.
June 5, 2018

Hello,

It is impossible to change a custom field type through the UI interface. The safest way is to create a new field and copy all values from the old field to the new field using an add-on like Power Scripts or ScriptRunner.

Raju Anumula June 5, 2018

Hi Alexey,

we are using script runner plugin, I am not expertized in a script, please guide me how to use a script in this case.

Thanks in advance.

Alexey Matveev
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 Leaders.
June 5, 2018

Your script would look like this. You can run it in the ScriptConsole of the ScriptRunner plugin. Kindly check the script first in a test environment.

import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.fields.config.FieldConfig
import com.atlassian.jira.issue.context.IssueContextImpl
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.Options
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
def findIssues(String jqlQuery) {
def issueManager = ComponentAccessor.issueManager
def user = ComponentAccessor.jiraAuthenticationContext.user
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
def searchProvider = ComponentAccessor.getComponent(SearchProvider.class)
def query = jqlQueryParser.parseQuery(jqlQuery)def results = searchProvider.search(query, user, PagerFilter.unlimitedFilter)
results.issues.collect { issue -> issueManager.getIssueObject(issue.id) }
}
def user = ComponentAccessor.jiraAuthenticationContext.user

CustomField cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("source field name")
CustomField cf1 = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("destination field name")
def jqlQuery = "Your JQL query to choose all required issues here"
def issues = findIssues(jqlQuery)issues.each{it -> log.error it.getCustomFieldValue(cf);

      cf1.updateValue(null, it, it.getCustomFieldValue(cf), new DefaultIssueChangeHolder());
}
Raju Anumula June 6, 2018

Thanks a lot Alexey. 

Alexey Matveev
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 Leaders.
June 6, 2018

You are welcome! Try this solution in a test environment first. If it works, kindly accept my answer. In this case other people with similair question will be able to find this answer.

0 votes
Yogesh Mude
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 Leaders.
June 5, 2018

HI @Raju Anumula

You can do this from backend but there is no way from UI.

Here is the documentation for the changing custom field type but making changes from backend are not recommended by Atlassian itself.

The ticket also has been created from this but the resolution will be Wont fix.

Suggest an answer

Log in or Sign up to answer