Unable to clear description field on changing project using Javascript

Vineela Durbha September 29, 2020

Hi Team,

I have written Javascript to set default description value for a project as below

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") {
//('oncreate')


if (document.getElementById("description").value =="") {
//alert('nodesc')

AJS.$("#description").val("<b>Context</b><h3>What is the requested change?</h3> \n <p>&ltdescribe the request here&gt</p> \n<h3>Why is this change needed?</h3> \n <p>&ltdescribe the motivation here&gt</p> \n<h3>What is the impact to existing process, tools, and stakeholders? </h3>(if known): \n <p>&ltdescribe the impact here&gt</p> \n<h3>Steps to perform/reproduce </h3> \n <p> <ol class= olnospace>&ltList the planned activities or steps to reproduce the fault (defects only)&gt</ol></p> \n<h3>Acceptance Criteria </h3> \n <p>&ltList the expected output to be completed before this ticket can be closed&gt </p> ");
}
}
}
}
else{
AJS.$("#description").val("")

}
});

 

When I am changing project,description field value is not getting cleared. Can anyone help me on the same?

1 answer

0 votes
Daniel Ebers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 21, 2020

Hi Vineela,

unfortunately there is no help under way but more a general hint: customized Java Script many times in the past caused trouble - it is not recommended anymore.

In cloud plans for example it is completely not possible to set it like this.

I saw instances where this was introduced many years ago and now the JS code was remove due to incompatibilities.

More stable it a solution using Behavious but the App needs payment.

Cheers,
Daniel

Suggest an answer

Log in or Sign up to answer