Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JiBrok/df30471f4cec93bf3c2d802803f9dba8 to your computer and use it in GitHub Desktop.
Save JiBrok/df30471f4cec93bf3c2d802803f9dba8 to your computer and use it in GitHub Desktop.
JiBrok, message field, JavaScript Example: update message with priority and select field
require(['jquery'], function($) {
function setCFValue(customfield_id, value){
$('#' + customfield_id).val(value).trigger('change')
}
function setMessage(title, body, messageType){
var jsonMessage = {}
jsonMessage.title = title
jsonMessage.body = body
jsonMessage.messageType = messageType
setCFValue(CF_ID_MESSAGE, JSON.stringify(jsonMessage))
}
function getPriority(){
return $('#priority').val()[0]
}
function getCFValue(customfield_id){
return $('#' + customfield_id).val()
}
//EDIT HERE
var CF_ID_MESSAGE = 'customfield_10200'
var CF_ID_SELECT = 'customfield_10301'
$('#priority').on('change', function(){
updateMessage()
})
$('#' + CF_ID_SELECT).on('change', function(){
updateMessage()
})
function updateMessage(){
if(['1'].indexOf(getPriority()) > -1){//1 - priority id
if(['-1'].indexOf(getCFValue(CF_ID_SELECT)) > -1){//-1 - select none
setMessage('BLOCKER', '<a>BLOCKER and seelct none </a>', 'error')
return
}
} else if(['2'].indexOf(getPriority()) > -1){//2 - priority id
if(['10104'].indexOf(getCFValue(CF_ID_SELECT)) > -1){//select option id
setMessage('Critical and select option', 'message', 'success')
return
}
} else if(['3', '4'].indexOf(getPriority()) > -1){
setMessage('Simple title', 'message', 'info')
return
}
setMessage('DEFAULT TITLE', 'DEFAULT MESSAGE', 'info')
return
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment