Requirement: Update 'Description' field based on Project (A) and Issue type
Project have their own Screens/Fields configurations
Issue Type - ~9; requirement to be applied to only 5
( Project A - applied configuration to; Project B - Nothing touched)
Below codes are working; but bugs are
1. While creating issue; project A is selected and issue type (any of 5) - description field is populated as expected
2. If project selection is changed from A to B - description field is still populated with old data
3. Description field should be refreshed as EMPTY as other project doesn't have any data/value to be populated in Description field.
Banner:
<script type='text/javascript'>
AJS.toInit(function () {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
jQuery("#issuetype-field").on("change", function () {
Despacito()
})
JIRA.bind(JIRA.Events.ISSUE_REFRESHED, function (el, cont) {
Despacito();
})
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, cont, reason) {
if (reason === JIRA.CONTENT_ADDED_REASON.dialogReady) {
Despacito();
}
})
JIRA.bind(JIRA.Events.INLINE_EDIT_SAVE_COMPLETE, function (e, context) {
Despacito();
})
JIRA.bind(JIRA.Events.INLINE_EDIT_STARTED, function (e, context) {
Despacito();
})
});
});
</script>
Description field: "DESCRIPTION OF DESCRIPTION FIELD IS UPDATED TO BELOW SCRIPT"
<script type="text/javascript">
if(document.getElementById("edit-issue-dialog")==null)
Despacito()
function Despacito() {
descriptionF = document.getElementById("description");
if(document.getElementById("create-issue-dialog")!=null)
descriptionF.value=" ";
if (document.getElementById("project-field") != null)
{
if (document.getElementById("project-field").value == null)
projectName = document.getElementById("project-field").innerHTML;
else
projectName = document.getElementById("project-field").value;
} else
{
if (document.getElementById("issue-create-project-name").innerHTML == null)
projectName = document.getElementById("issue-create-project-name").value;
else
projectName = document.getElementById("issue-create-project-name").innerHTML;
}
if (projectName == "NS Delivery Change Planning (DCP)" || projectName=="NS Delivery Change Planning")
{
descriptionF.value=" ";
if (document.getElementById("issuetype-field") == null)
issueType = document.getElementById("issue-create-issue-type").innerHTML;
else
issueType = document.getElementById("issuetype-field").value;
if (issueType == "Training Request") {
descriptionF.value = "some data";
} else if (issueType == "Agenda Proposal") {
descriptionF.value = "some data";
} else if (issueType == "CRI – Request Transfers") {
descriptionF.value = "some data";
} else if (issueType == "Maintenance") {
descriptionF.value = "some data";
} else if (issueType == "Change Request") {
descriptionF.value = "some data";
} else {
descriptionF.value = " ";
}
}
}
</script>