Forums

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

duedate field on various languages

ioann sys February 1, 2018

Hello! i need change duedate field, if user are administator. Next sript woring, but it not work in Russian version. 

import com.atlassian.jira.component.ComponentAccessor

if(!getActionName()?.startsWith("Create"))
{
return
}

// define current user
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def duedateField = getFieldById("duedate")

if( user.name == "admin" || user.name == "sysadmin" )
{
def targetDate = new Date() + 365
duedateField.setFormValue(targetDate.format("dd/MMM/yy"))
}

For EN/UK localies a code targetDate.format("dd/MMM/yy") is correct. on the RU locale i get error about format dd/MMM/yy, where i need use d/MMM/yy (one 'd').

1 answer

1 vote
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.
February 1, 2018

I never tried the code with behaviour but it can help you. It gets user date format

ap = ComponentAccessor.getComponentOfType(ApplicationProperties.class);

String str = ap.getDefaultBackedString(APKeys.JIRA_DATE_PICKER_JAVA_FORMAT);
lc= ComponentAccessor.getJiraAuthenticationContext().getLocale()
SimpleDateFormat sdfr = new SimpleDateFormat(str,lc);
ioann sys February 1, 2018

unable to resolve SimpleDateFormat

What should I import to make your class work?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events