Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

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

Scriptrunner example fragment does not work

Jakub Cieplinski
Contributor
July 18, 2022

So, I've tried the "Hiding Menu Button Using JavaScript" from this scriptrunner doc.

https://docs.adaptavist.com/sr4js/6.42.0/features/script-fragments/custom-fragments/web-resource?utm_source=product-help

 

And it not only does not hide the clone button, it instead hides the sidebar on issues.

We are running Jira 8.20.9, I've tried it before, i think on 8.13 and it worked. Did the functionality stop working because of jira update? Is the doc no longer valid?

Screenshot_102.png

2 answers

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 23, 2022

Hi @Jakub Cieplinski 

Could you please share the previously working fragment code and a screenshot of your fragment configuration so I can review it?

Also, what is the current version of ScriptRunner that you are using?

Thank you and Kind regards,

Ram

Jakub Cieplinski
Contributor
July 24, 2022
(function ($) {
$(function () {
/**
* Binding is required for link such as
* http://localhost:8080/jira/projects/JRA/issues/JRA-4?filter=allopenissues
*/
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (event, $context, reason) {
if (reason === JIRA.CONTENT_ADDED_REASON.pageLoad || reason === JIRA.CONTENT_ADDED_REASON.panelRefreshed) {
hideSAPTransition();
}
});

hideSAPTransition();
});


function hideSAPTransition() {
var projectKey = "HI";
var issue = JIRA.Issue.getIssueKey();
if (typeof (issue) !== "undefined") {
var currentProject = issue.substr(0, issue.indexOf('-'));
if (currentProject == projectKey) {
$("#action_id_1081").hide(); //do not click action for sap transition
}
}
}
})(AJS.$);

 

I also tried the atl.general contexScreenshot_103.png

Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 5, 2022

Hi @Jakub Cieplinski

Have you set the path where your javascript is stored using the setenv.sh / setenv.bat file as mentioned in the Adaptavist Documentation?

Thank you and Kind regards,

Ram

0 votes
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 18, 2022

Hi @Jakub Cieplinski  

For this you have to use Script Fragment feature of Script runner. In Script Fragment use "Hide System or Plugin UI element". 

Fragment Hide.PNG

In Hide What section, select clone-issue only

 

Configuration.PNG

 

In Condition Block , enter the condition based on your requirement :- 

import com.atlassian.jira.component.ComponentAccessor

if(jiraHelper.project?.key == "PROJECTKEY") {
false
} else {
true
}

 Hope it Works for you!

OR

you can check this link :- https://mraddon.blog/2017/03/30/how-to-remove-the-clone-option-in-jira-projects/

Thanks,

V.Y

Jakub Cieplinski
Contributor
July 18, 2022

Hi, the clone option was not really the point. I'm not trying to hide clone option but something else, the script is just slightly modified clone option so I figured to say it's that.

 

The point is, is that these kinds of fragments break jira ui

Like Vikrant Yadav likes this
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 18, 2022

Hi, The script is to Hide Clone option from Menu and it doesn't break jira UI.

If you apply web panel at wrong location in that case it might break Jira UI.

Hide UI elements only hide options and nothing else.

There are multiple script fragment types which one your tried ?

May i know your exact purpose for using script fragment ?

Thanks 

Jakub Cieplinski
Contributor
July 18, 2022

Like I said in my original message, I used the exact script from "Hiding Menu Button Using JavaScript" section of this article along with other instructions provided for it

https://docs.adaptavist.com/sr4js/6.42.0/features/script-fragments/custom-fragments/web-resource?utm_source=product-help

 

And as seen in the screenshot, it does break Jira UI. Disabling the script fixes the issue, so the obvious conclusion is that this functionality breaks the Jira UI.

 

My exact purpose is to hide one workflow button(we do NOT want to do this through workflow conditions). It was working before jira upgrade but stopped after it. I figured something might be wrong with my script and I applied the one provided by adaptavist to check it out that way, turns out it doesn't work with it either. 

The only differences between my script and the one in the wiki is changed project key and instead of hiding clone button it does

$("#action_id_1081").hide();
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 18, 2022

@Ram Kumar Aravindakshan _Adaptavist_   Kindly help Jakub regarding Script Fragment.  

Suggest an answer

Log in or Sign up to answer