Created
October 23, 2019 21:15
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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