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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,555,410
Community Members
 
Community Events
184
Community Groups

Remove ScriptRunner fragment which causing errors

 

In this article i will explain how you can remove a ScriptRunner fragment if you added it and its causing errors. 

For my case , I added a fragment to show data on header like below

 







Later on , I updated the html and forgot to close the tag and the result were when ever i was loading any page , was getting this error and no one able to access Jira



Here are the steps which you can follow to remove any fragment through rest if its causing error.

Do a Get Call 

http://localhost:9090/rest/scriptrunner/latest/fragments 

You will see results like below


[
{
@class: "com.onresolve.scriptrunner.fragments.model.CustomWebItemCommand",
id: "58269541-fa01-4c87-a695-0e720222b392",
version
14,
ownedBynull,
disabledfalse,
FIELD_NOTES"showUpdateEpicDialogBox",
canned-script"com.onresolve.scriptrunner.canned.jira.fragments.CustomWebItem",
FIELD_KEY"mybtn",
FIELD_WEIGHTnull,
FIELD_SECTION"operations-top-level",
FIELD_MENU_LABEL"Update Epic Issues",
FIELD_MENU_LABEL_KEYnull,
FIELD_LINK_CONDITION
{
script"issue.issueType?.name.toString()=="Epic" ",
scriptPathnull,
parameters: { }
},
FIELD_LINK_DESTINATION"/rest/scriptrunner/latest/custom/showUpdateEpicDialogBox?issueKey=${issue.key}",
FIELD_STYLE_CLASSnull,
FIELD_DO_WHAT"RUN_CODE_SHOW_DIALOG",
name"Custom web item"
},
{
@class"com.onresolve.scriptrunner.fragments.model.CustomWebItemCommand",
id"ae3929ce-f5fa-4642-a53d-07b5778090c8",
version7,
ownedBynull,
disabledfalse,
FIELD_NOTES"epic parent",
canned-script"com.onresolve.scriptrunner.canned.jira.fragments.CustomWebItem",
FIELD_KEY"epicparent",
FIELD_WEIGHTnull,
FIELD_SECTION"operations-top-level",
FIELD_MENU_LABEL"EpicParent",
FIELD_MENU_LABEL_KEYnull,
FIELD_LINK_CONDITIONnull,
FIELD_LINK_DESTINATION"/rest/scriptrunner/latest/custom/showDialog",
FIELD_STYLE_CLASSnull,
FIELD_DO_WHAT"RUN_CODE_SHOW_DIALOG",
name"Custom web item"
},
{
@class"com.onresolve.scriptrunner.fragments.model.CustomWebPanelCommand",
id"35317b57-d843-41b7-a80f-4d53514fd990",
version41,
ownedBynull,
disabledfalse,
FIELD_NOTES"SLA",
canned-script"com.onresolve.scriptrunner.canned.jira.fragments.CustomWebPanel",
FIELD_KEY"sla",
FIELD_WEIGHTnull,
FIELD_LOCATION"atl.header",
FIELD_MENU_LABEL"sla",
FIELD_LINK_CONDITION
{
script"import com.atlassian.jira.component.ComponentAccessor def loggedinuser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() if (loggedinuser) { return 1 } else { return 0 }",
scriptPathnull,
parameters: { }
},
FIELD_CLASS_NAME
{
script"package com.elm.scriptrunner.upwork.BMCRemedy.Fragments import com.atlassian.jira.bc.issue.search.SearchService import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.user.ApplicationUser import com.atlassian.jira.web.bean.PagerFilter import groovy.transform.Field import org.apache.log4j.Logger @Field String execUser = "ramzan" // provide the username to authorize the request to be updated. @Field botUser=executeWithUser() @Field String S1="'Customer Request Type' ='S1 - Report Circuit Down (NEVT)' " @Field String S2="'S2 - Report Link Flapping/Intermittent, Packet Loss (NEVT)' " @Field String S3="'S3 - Network Slowness (NEVT)' " writer.write(""" <div style='background-color: darksalmon; text-align: center'> <b>S3-Open Tickets </b>: ${findIssues(S3).size()}</div> <div style='background-color: silver; text-align: center'> <b>S2-Open Tickets</b>: ${findIssues(S2).size()}</div> <div style='background-color: teal; text-align: center'> <b>S3-Open Tickets</b>: ${findIssues(S1).size()}</div> """) def findIssues(String jqlSearch) { def searchService = ComponentAccessor.getComponent(SearchService) def issueManager = ComponentAccessor.getIssueManager() SearchService.ParseResult parseResult = searchService.parseQuery(botUser, jqlSearch) def searchResult = searchService.search(botUser, parseResult.getQuery(), PagerFilter.getUnlimitedFilter()) def results = searchResult.results.key logs("Matching Issues : ${results}") return results } ApplicationUser executeWithUser() { ApplicationUser executingAdmin = ComponentAccessor.getUserManager().getUserByName(execUser) ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(executingAdmin) return executingAdmin } def logs(def lg) { def log = Logger.getLogger("com.onresolve.jira.groovy") logs(lg) }",
scriptPathnull,
parameters: { }
},
FIELD_STYLE_CLASSnull,
name"Show a web panel"
]}

 

 


Get required id of the fragment and then do a DELETE request call by using URI as below

 

Request Type: DELETE
URI: http://localhost:9090/rest/scriptrunner/latest/fragments/35317b57-d843-41b7-a80f-4d53514fd990



Please change the host url and id as per your instance.
That's it, fragment will be deleted and you can refresh Jira and it will work perfectly.

 

Visit my blog: https://www.techclimbs.com/2020/06/delete-scriptrunner-custom-fragment.html

2 comments

M Amine
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 26, 2020
Taranjeet Singh
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 22, 2020

Thanks for this useful tip @Muhammad Ramzan_Atlassian Certified Master_ !

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events