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').
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);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.