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 Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

401 views 6 10
Read article

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