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>
Add these calls along with NEW_CONTENT_ADDED as well
Despacito()
setTimeout(hidePriorityField , 150)
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()
})
what does 'reason' should be here and also how can make sure banner script will be running only where issue-create-dialog is open? Anyhow- i want it to run on both new tab and dialog box open scenario.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you want the script to run only on issure-create-dialog then you would need to put a condition check on it.
surround your scrpit with
<script>
(function($) {
// This is for when an issue is being created while
// opened in a new window tab
AJS.toInit(function(){
if (AJS.$("#issue-create-submit").val()=="Create" || AJS.$("#create-issue-submit").val()=="Create"){
// Your code
}
})
// This is when issue is being created via dialog box popup.
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
if (AJS.$("#issue-create-submit").val()=="Create" || AJS.$("#create-issue-submit").val()=="Create"){
// your code.
}
});
})(AJS.$);
</script>
This will also take care when project is switched from A to B.
Ignore the above Events.
Wrap your code and adjust it into this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tayaab,
I've added your 1st provided function to banner - Question code updated
THIS IS WORKING AS ALL GOOD ON BOTH THE CREATE SCREEN; but discovered something else
When I'm on Issue View screen and try to edit -
* On 1st click - Edit dialog box is opening as normal
* Then if I cancel/Escape it and click on 'Edit' again - it just shows 'loading indicator' continous without any stop.
* Until and un-less page is refresh - edit box isn't getting opened.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmm, this is wierd behaviour.
Because the JavaScirpt in your code doesn't even target the Edit Screen.
The submit value button on "Edit" screen, is Update, while in the both of our If Conditions, we are telling it to run where id = issue-create-submit.
So it shouldn't even run over there.
Maybe try deleting the browser Cache and then trying it again.
Because sometimes it does messes up with JavaScript.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tayyab,
Now, we've upgraded to 7.3 wherein we've Visual/Text mode for description field. Now when the issue is selected the description field isn't getting populated properly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi! I'm running an adapted version of this script, for summary field, on Jira Server 7.11.
Works Great!
I putted all the javascript on banner.
Tks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have below javascript to set description value, but the description field is not clearing when I am changing the project. Can you help on this if you have any ideas
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e, context, reason) {
var project = AJS.$('#issue-create-project-name').text();
var projectn = AJS.$('#project').val();
var isCreateIssuePage = AJS.$('#create-issue-dialog').is(':visible');
var itype =AJS.$('#issue-create-issue-type').text();
var issueType = AJS.$('#issuetype-field').val();
if(project == 'Support - Lifecycle Tools' || projectn =='11805'){
//alert('lcsppt')
if (issueType == "Defect" || issueType == "Task" || itype == "Defect" || itype == "Task"){
//alert('itype')
if (isCreateIssuePage == true || AJS.$('#content .aui-page-header-main h1').text() == "Create Issue") {
if (document.getElementById("description").value =="") {
//alert('nodesc')
AJS.$("#description").val("<b>Context</b><h3>What is the requested change?</h3> \n <p><describe the request here></p> \n<h3>Why is this change needed?</h3> \n <p><describe the motivation here></p> \n<h3>What is the impact to existing process, tools, and stakeholders? </h3>(if known): \n <p><describe the impact here></p> \n<h3>Steps to perform/reproduce </h3> \n <p> <ol class= olnospace><List the planned activities or steps to reproduce the fault (defects only)></ol></p> \n<h3>Acceptance Criteria </h3> \n <p><List the expected output to be completed before this ticket can be closed> </p> ");
}
}
}
}else{
AJS.$("#description").val("");
}
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.