javascript is broken after upgrade from 5.2.11 to 6.2.7

Hi,

One of our customfield has a huge java script incorporated in the description(I was not the one who wrote it sad). Apparently it copies values from parent task to sub-task . The script no longer works after the upgrade. Any suggestion/help?

 

Cheers,

Priya

3 answers

Hi Priya,

To help you with this further, please take a moment to provide the

  • Full Javascript that is being used in the field
  • Custom field type
  • What is the purpose of this javascript?

We will need to information to better understand what the javascript does so we can try to reproduce locally and check if there's a way to fix it.

Cheers,

Hi Pietro,

The script does multiple things. I shall list them below in detail,

 

Parent task

There is a behaviour added in the paresnt task to copy the Roadname (text field) field to Summary. and the Summary field is hidden from the screen using the below

Behaviour

FormField roadNameField = getFieldById (fieldChanged)

getFieldById("summary").setFormValue(roadNameField.getFormValue())

 

Script to hide Summary

<script type="text/javascript">
AJS.$(function () {
if (AJS.$("#assign-issue-submit").length == 0) AJS.$("#summary").parent().css("visibility", "hidden");
});
</script>

 

There is a multi-select list caleed Region with defined values. 

SubTask

The below javascript is added in the field name  Speed Zone Road Name(text field)

which should be copied from the Roadname field of the Parent Task(also the sub-task summary should be set to the same value)


and the LGA (multi-select field) is restricted to few options depending on the Region picked on the Parent task.

 

 

+++++++++++++++

<script type="text/javascript">
AJS.$(function () {
var __parentRef = AJS.$("#parent_issue_summary");
//alert("__parentRef:" + __parentRef);
//alert("__parentRef.value:" + __parentRef.value);
//alert("__parentRef.val():" + __parentRef.val());
AJS.$.getJSON(AJS.$('input[title="baseURL"][type="hidden"]').val() + "/rest/api/latest/issue/" + __parentRef.attr("href").substring(14), function(data){
var __fields = data.fields;
var __roadName = AJS.$("#customfield_11918");
var __summary = __fields.summary;
if (__roadName.val().length == 0)
{
__roadName.val(__summary);
}
if (AJS.$("#assign-issue-submit").length == 0) AJS.$("#summary").parent().css("display", "none");
var __list = AJS.$("#customfield_11927");
var __selected = __list.val();
__list.val("-1");
__list[0].options.length = 0;
var __region = data.fields.customfield_11201.value;
alert("Region: " + __region);
alert("Roadname: " + __roadName);
if (__region === "Western")
{
__list.append('<option value="15035">Bathurst Regional</option><option value="15036">Blayney</option><option value="15037">Bogan</option><option value="15038">Bourke</option><option value="15039">Brewarrina</option><option value="15040">Broken Hill</option><option value="15041">Cabonne</option><option value="15042">Central Darling</option><option value="15043">Cobar</option><option value="15044">Coonamble</option><option value="15045">Cowra</option><option value="15046">Dubbo</option><option value="15047">Forbes</option><option value="15048">Gilgandra</option><option value="15049">Lachlan</option><option value="15050">Lithgow</option><option value="15051">Mid Western Regional</option><option value="15052">Moree Plains</option><option value="15053">Narrabri</option><option value="15054">Narromine</option><option value="15055">Oberon</option><option value="15056">Orange</option><option value="15057">Parkes</option><option value="15058">Un-Incorporated Area</option><option value="15059">Walgett</option><option value="15060">Warren</option><option value="15061">Warrumbungle</option><option value="15062">Weddin</option><option value="15063">Wellington</option>');
}
else if (__region === "Sydney")
{
__list.append('<option value="15157">Ashfield</option><option value="15158">Auburn</option><option value="15159">Bankstown</option><option value="15160">Blacktown</option><option value="15161">Blue Mountains</option><option value="15162">Botany Bay</option><option value="15163">Burwood</option><option value="15164">Camden</option><option value="15165">Campbelltown</option><option value="15166">Canada Bay</option><option value="15167">Canterbury</option><option value="15168">Fairfield</option><option value="15169">Hawkesbury</option><option value="15170">Holroyd</option><option value="15171">Hornsby</option><option value="15172">Hunters Hill</option><option value="15173">Hurstville</option><option value="15174">Kogarah</option><option value="15175">Ku-ring-gai</option><option value="15176">Lane Cove</option><option value="15177">Leichhardt</option><option value="15178">Liverpool</option><option value="15064">Manly</option><option value="15065">Marrickville</option><option value="15066">Mosman</option><option value="15067">North Sydney</option><option value="15068">Parramatta</option><option value="15069">Penrith</option><option value="15070">Pittwater</option><option value="15071">Randwick</option><option value="15072">Rockdale</option><option value="15073">Ryde</option><option value="15074">Strathfield</option><option value="15075">Sutherland</option><option value="15076">Sydney</option><option value="15077">The Hills</option><option value="15078">Warringah</option><option value="15079">Waverley</option><option value="15080">Willoughby</option><option value="15081">Woollahra</option>');
}
else if (__region === "South West")
{
__list.append('<option value="15179">Albury</option><option value="15180">Balranald</option><option value="15181">Berrigan</option><option value="15182">Bland</option><option value="15183">Boorowa</option><option value="15184">Carrathool</option><option value="15185">Conargo</option><option value="15186">Coolamon</option><option value="15187">Cootamundra</option><option value="15082">Corowa</option><option value="15083">Deniliquin</option><option value="15084">Greater Hume</option><option value="15085">Griffith</option><option value="15086">Gundagai</option><option value="15087">Harden</option><option value="15088">Hay</option><option value="15089">Jerilderie</option><option value="15090">Junee</option><option value="15091">Leeton</option><option value="15092">Lockhart</option><option value="15093">Murray</option><option value="15094">Murrumbidgee</option><option value="15095">Narrandera</option><option value="15096">Temora</option><option value="15097">Tumbarumba</option><option value="15098">Tumut</option><option value="15099">Urana</option><option value="15100">Wagga Wagga</option><option value="15101">Wakool</option><option value="15102">Wentworth</option><option value="15103">Yass Valley</option><option value="15104">Young</option>');
}
else if (__region === "Southern")
{
__list.append('<option value="15105">Bega Valley</option><option value="15106">Bombala</option><option value="15107">Cooma-Monaro</option><option value="15108">Eurobodalla</option><option value="15109">Goulburn Mulwaree</option><option value="15110">Kiama</option><option value="15111">Palerang</option><option value="15112">Queanbeyan</option><option value="15113">Shellharbour</option><option value="15114">Shoalhaven</option><option value="15115">Snowy River</option><option value="15116">Upper Lachlan</option><option value="15117">Wingecarribee</option><option value="15118">Wollondilly</option><option value="15119">Wollongong</option>');
}
else if (__region === "Northern")
{
__list.append('<option value="15120">Armidale Dumaresq</option><option value="15121">Ballina</option><option value="15122">Bellingen</option><option value="15123">Byron</option><option value="15124">Clarence Valley</option><option value="15125">Coffs Harbour</option><option value="15126">Glenn Innes Severn</option><option value="15127">Gunnedah</option><option value="15128">Guyra</option><option value="15129">Gwydir</option><option value="15130">Inverell</option><option value="15131">Kempsey</option><option value="15132">Kyogle</option><option value="15133">Lismore</option><option value="15134">Liverpool Plains</option><option value="15135">Nambucca</option><option value="15136">Port Macquarie - Hastings</option><option value="15137">Richmond Valley</option><option value="15138">Tamworth Regional</option><option value="15139">Tenterfield</option><option value="15140">Tweed</option><option value="15141">Uralla</option><option value="15142">Walcha</option>');
}
else // if (__region === "Hunter")
{
__list.append('<option value="15143">Cessnock</option><option value="15144">Dungog</option><option value="15145">Gloucester</option><option value="15146">Gosford</option><option value="15147">Great Lakes</option><option value="15148">Greater Taree</option><option value="15149">Lake Macquarie</option><option value="15150">Maitland</option><option value="15151">Muswellbrook</option><option value="15152">Newcastle</option><option value="15153">Port Stephens</option><option value="15154">Singleton</option><option value="15155">Upper Hunter</option><option value="15156">Wyong</option>');
}
__list.val(__selected);
(function($) {
AJS.$("#customfield_11927 option[value='-1']").remove(); // Removes the default value "None"
function convertMulti(id){
if (AJS.$('#'+id+"-textarea").length == 0){
new AJS.MultiSelect({
element: $("#"+id),
itemAttrDisplayed: "label",
errorMessage: AJS.params.multiselectComponentsError
});
}
}

AJS.toInit(function(){
convertMulti("customfield_11927");
});

JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
AJS.$("#customfield_11927 option[value='-1']").remove(); // Removes the default value "None"
convertMulti("customfield_11927");
});
})(AJS.$);
});
AJS.$("#customfield_11915 option[value='15200']").remove();
AJS.$("#customfield_11835 option[value='14828']").remove();
var h2 = AJS.$("h2");
if (h2.text().indexOf("Edit Issue") >= 0) h2.text("Edit Speed Zone");
else h2.text("Create Speed Zone");
});
</script>

 

Cheers,

Priya

 

The script seems to be broken here,

AJS.$.getJSON(AJS.$('input[title="baseURL"][type="hidden"]').val() + "/rest/api/latest/issue/" + __parentRef.attr("href").substring(14), function(data){

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...

689 views 6 13
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