Description
Hi,
I would like to change the date format in the 'email content' of the SLA notifier. I currently have the below code but it appears as '2018-09-22 13:55:00.0'.
Can it be set to normal format?
Log On : $
{issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_11201'))}
Log Off : $
{issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_11202'))}
Network Engineer : $
{issue.getCustomFieldValue($customFieldManager.getCustomFieldObject('customfield_11302')).getDisplayName()}
The way to avoid this is to make your mapping global (all issue type and all projects).
Then detect in your script what the project and issue types are.
If you have a need to have different defaults for different project/issuetype, you will need to account for that in your script. For example:
def mapping = [
PKEY1 : [
Story : [
desc: "default Story description for project PKEY1",
accept: "default Story acceptance criteria for PKEY1"
],
Task : [
desc: "default Task description for project PKEY1"
]
],
KEY2 : [ /*other defaults here for KEY2 projects*/]
]
if (getActionName() == "Create"){
def proj = issueContext.projectObject
def issueType = issueContext.issueType
def acceptFld= getFieldByName("Acceptance Criteria")
def descFld = getFieldById('description')
def defaults = mapping[proj.key][issueType.name]
if(defaults?.desc){
descFld.setFormValue(defaults.desc)
} else {
descFld.setFormValue("")
}
if(defaults?.accept){
acceptFld.setFormValue(defaults.accept)
} else {
acceptFld.setFormValue("")
}
}
One warning I should add...
The default jira behavior (when you don't use Scriptunner behavior to set form values) is to keep the text typed by the user when they change project /issue type.
So with a script like what I suggested, you could end up wiping out user's entry if they decide they want to change issue type (e.g. when changing between 2 issue types of a project without defaults).
One possible workaround is before setting the value to "" is to compare the value with all default options from all projects and issue types, and only set the form to "" if the form currently contains a known default.
The minute the user makes a change to the text, they own that text and changing type or project won't re-set the default value.
Another approach (untested) is to modify the field description dynamically with scriptrunner behavior and include a link that the user can click to re-set the field to the default. But you will have to populate that description with some javascript to replace the text. no small feat.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks so much. Still some work to be done on the script, but yea the mapping was the main issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you provide the code that implement the workaround please?
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.