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);
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.