Issue with Javascript in the description field of a custom field

Hi,

https://confluence.atlassian.com/display/JIRA/Displaying+a+Field+Based+on+Another+Field+Selection

I am using above link to manipulate the value of the custom field based on some other custom field values in the javascript code. The problem I am facing is that once I open a screen where the below custom field is shown, it doesn't take the formula below. But once I open the screen again, it takes the formula below.

Please help me in resolving this.

Regards

Deepak Bhatia

============================================================================

if(document.getElementById('customfield_10163').options[document.getElementById('customfield_10163').selectedIndex].text == "None")
{
val10163=0;
}
else
{
val10163=parseInt(document.getElementById('customfield_10163').options[document.getElementById('customfield_10163').selectedIndex].text);
}

if(document.getElementById('customfield_10164').options[document.getElementById('customfield_10164').selectedIndex].text == "None")
{
val10164=0;
}
else
{
val10164=parseInt(document.getElementById('customfield_10164').options[document.getElementById('customfield_10164').selectedIndex].text);
}

if(document.getElementById('customfield_10165').options[document.getElementById('customfield_10165').selectedIndex].text == "None")
{
val10165=0;
}
else
{
val10165=parseInt(document.getElementById('customfield_10165').options[document.getElementById('customfield_10165').selectedIndex].text);
}

if(document.getElementById('customfield_10166').options[document.getElementById('customfield_10166').selectedIndex].text == "None")
{
val10166=0;
}
else
{
val10166=parseInt(document.getElementById('customfield_10166').options[document.getElementById('customfield_10166').selectedIndex].text);
}

if(document.getElementById('customfield_10162').options[document.getElementById('customfield_10162').selectedIndex].text == "None")
{
val10162=0;
}
else
{
val10162=parseFloat(document.getElementById('customfield_10162').options[document.getElementById('customfield_10162').selectedIndex].text);
}

finalvalue = ((val10163+val10164+val10165+val10166)/4)*val10162;

document.getElementById('customfield_14661').value=finalvalue.toFixed(1);

3 answers

0 vote
Mizan Community Champion Jan 21, 2013

You can also use behaviours plugin for this ... See this similar example

Thanks but I think it is not available for JIRA 5.1.6.

0 vote
Mizan Community Champion Jan 21, 2013

AFAIK it is available . you will need to check if you need to disable inline editing / it will automatically disable for these fields only .

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,308 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot