Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

Mohammed Amine Community Leader Sep 26, 2020

thank you @Muhammad Ramzan for this tip.

Like Muhammad Ramzan likes this
Taranjeet Singh Community Leader Nov 22, 2020

Thanks for this useful tip @Muhammad Ramzan !

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Jira Software

Why flagging Jira issues is so cool?

Adding a flag to an issue is a cool way to say it is blocked. Also, you can add a comment as part of the same action from a board. But what if you want to do the same from the issue detail view? Th...

78 views 2 6
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you