Last active
September 4, 2020 19:21
-
-
Save JiBrok/1d308d9e393c739790462d35b5cdb305 to your computer and use it in GitHub Desktop.
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.
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
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) | |
} | |
} | |
}); | |
} | |
function hideMessage(messageFieldId){ | |
AJS.$("#rowFor" + messageFieldId).hide() | |
} | |
function areAllFieldsEmpty(issue, fieldIds){ | |
for(var i = 0; i < fieldIds.length; i++){ | |
var fieldId = fieldIds[i] | |
if(issue.fields[fieldId] != null){ | |
return false | |
} | |
} | |
return true | |
} | |
//The script will check the custom fields on the view issue screen. If all fields are empty, the message banner will be hidden. | |
if(JIBROK_MESSAGE_FIELD_CONTEXT == "VIEW_ISSUE"){//version 3.1.7+ or set JavaScript context - Issue view screen | |
var customFieldIds = ["customfield_10201", "customfield_10202"]//fields will be check on null value | |
var messageFieldId = "customfield_10013" | |
checkFieldsAreEmptyAndHideMessage(customFieldIds, messageFieldId) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment