Skip to content

Instantly share code, notes, and snippets.

@JiBrok
JiBrok / Set message as JSON.groovy
Last active Sep 13, 2020
Update message from ScriptRunner Behaviours
View Set message as JSON.groovy
/*
messageType values: success, info, warning, error, change (Type "Change" works only for "Show as flag - No" and Jira 8.4.0+), SIMPLE_VIEW
viewVersion: v1 (standard), v2 (big)
{
"title": "Test title",
"body": "test body",
"messageType": "info",
"asFlag": true,
@JiBrok
JiBrok / Hide message.groovy
Last active Sep 13, 2020
JiBrok, message field, ScriptRunner Behaviours Example: hide message
View Hide message.groovy
def field = getFieldById("customfield_10000")
field.setHidden(true)
@JiBrok
JiBrok / update message with bundled select(SD-create).js
Last active Sep 11, 2020
JiBrok, message field, JavaScript Example: update message on Service Desk Portal(create request) with bundled select from app "Extensions for Jira Service Desk"
View update message with bundled select(SD-create).js
require(['jquery'], function($) {
var lastSelectedOption = null;
function setMessage(message){
message.jibrokMessageKey = true //Require for Service Desk
AJS.$('#' + CF_ID_MESSAGE).text(JSON.stringify(message)).trigger('change')//Service Desk create request
}
//edit here ->
var CF_ID_MESSAGE = 'customfield_10200'
@JiBrok
JiBrok / Notification that this is a production environment.js
Last active Sep 3, 2020
Jira announcement banner: Notification that this is a production environment and disabling plugin install
View Notification that this is a production environment.js
<script>
AJS.toInit(() => {
var baseUrl = "http://localhost:2990/jira"
var upmUrl = "/plugins/servlet/upm"
var worklfowUrl = "/secure/admin/workflows"
function isWorkingTime(){
return new Date().getHours() > 7 && new Date().getHours() < 22
}
@JiBrok
JiBrok / hide message if all fields are empty(View issue).js
Last active Sep 4, 2020
JiBrok, message field, JavaScript Example: The script will check the custom fields on the view issue screen. If all fields are empty, the message banner will be hidden.
View hide message if all fields are empty(View issue).js
function checkFieldsAreEmptyAndHideMessage(fieldIds, messageFieldId){
AJS.$.ajax({
url: AJS.contextPath() + '/rest/api/2/issue/' + JIRA.Issue.getIssueId() + "?fields=" + fieldIds.join(),
type: "GET",
async: false,
success: function(issue) {
if(areAllFieldsEmpty(issue, fieldIds)){
hideMessage(messageFieldId)
}
}
@JiBrok
JiBrok / update and hide message with 2 conditions by select fields.js
Created Oct 31, 2019
JiBrok, message field, JavaScript Example: update and hide message with 2 conditions by select fields
View update and hide message with 2 conditions by select fields.js
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;
@JiBrok
JiBrok / update and hide message with 2 conditions by select fields(Service Desk).js
Last active Apr 2, 2020
JiBrok, message field, JavaScript Example: update and hide message with 2 conditions by select fields(Service Desk)
View update and hide message with 2 conditions by select fields(Service Desk).js
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
}
@JiBrok
JiBrok / update message with priority and select field(SD).js
Created Oct 23, 2019
JiBrok, message field, JavaScript Example: update message with priority and select field(Service Desk)
View update message with priority and select field(SD).js
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
}
@JiBrok
JiBrok / update message with priority(SD).js
Created Oct 23, 2019
JiBrok, message field, JavaScript Example: update message with priority(Service Desk).js
View update message with priority(SD).js
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
}
@JiBrok
JiBrok / update message on create(SD).js
Created Oct 23, 2019
JiBrok, message field, JavaScript Example: update message on create(Service Desk).
View update message on create(SD).js
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
}
You can’t perform that action at this time.