Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How can we clear custom field value using JavaScript

Amit Girme June 4, 2012

Is there any way to clear the custom field value using the javascript in its description. This should be done whenever issue is getting created & cloned?

Provided the custom field is "text field" with wiki style renderer.

I have refered https://developer.atlassian.com/pages/viewpage.action?pageId=4227208 but it is not helpful.

Also tried code as

<script type="text/javascript">
target = document.getElementById("customfield_1000000");
function clear()
{
target.value = "null";
}
var createbutton = document.getElementById("Create");
createbutton.onclick=clear
</script>

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Amit Girme June 10, 2012

Clearing field on Create Issue is possible using JavaScript. but for cloning it is not because picking information from CloneIssueDetails.jspa. So performed it through database script.

I dont like to install plugins for the other way achievable or single task queries. If multiple benefits are there then it make sense to install external plugin. :-)

1 vote
atul June 4, 2012

Hey Amit,

Yes you can do this.

Put this code in the description of very first filed of Jira Form.

For Example very first field id is = customfield_xxxxx and Terget field ID is =customfield_yyyyy

So below code will execute as user fill any value in the First field and controll move to another field.

<script>
AJS.$(document).ready(function(){

AJS.$("input[name=customfield_xxxxx]").blur(function () {
var target= document.getElementsByName("customfield_yyyyy")[0];
target.value = "";

});

});
</script>

Let me know if you have further question.

Regards,

Atul

Amit Girme June 5, 2012

Hi Atul,

Thanks for your response. I want to get the field clear while cloning. I achieved the clearance of field while creating issue but via different script as

&lt;script type="text/javascript"&gt;

target = document.getElementById("customfield_YYYYY");
function clear()
{
target.value = "";
}
var createForm = document.getElementById("issue-create");
createForm.onsubmit=clear;
&lt;/script&gt;

but this code is not working when we are cloning the issue.

var createClone = document.getElementById("assign-issue-submit")

might be because it is picking values from CloneIssueDetails.jspa page and not from the live page.

Further the script you given is not working for cloning. I put it in Summary which is the only field you can enter while cloning

TAGS
AUG Leaders

Atlassian Community Events