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/cc3c2a1a02d99a0116d006ce708bd8ff to your computer and use it in GitHub Desktop.
Save JiBrok/cc3c2a1a02d99a0116d006ce708bd8ff to your computer and use it in GitHub Desktop.
JiBrok, message field, JavaScript Example: update message with priority and select field(Service Desk)
require(['jquery'], function($) {
function setMessage(title, body, messageType){
var jsonMessage = {}
jsonMessage.title = title
jsonMessage.body = body
jsonMessage.messageType = messageType
jsonMessage.jibrokMessageKey = true //Require for Service Desk
$('#' + CF_ID_MESSAGE).text(JSON.stringify(jsonMessage)).trigger('change')//Service Desk create request
}
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