The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

Script Fragments - How to add JS to a Web item

Roberto L
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
January 5, 2018

Hello Community,

I would like to know if there is a way to have HTML code in a Web Item and have JS code that modifies the HTML code.

I want to implement a sort of search box.

I envision utilizing a simple text area where people will input words and a button "search".

Button search will be hooked up to a Rest EndPoint.

I want it so when I click search JS grabs whatever is in the text area and appends it to the end of the Rest EndPoint URL.

So that I can grab the everything at the end of the Rest Endpoint URL via the "additionalPath" method.

Is this possible?

-Roberto

 

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

2 votes
Answer accepted
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
January 5, 2018

Hello,
I think it is possible. But your solution would be too difficult to support. I do not think you should use ScriptRunner for the task. But if you still want to do it , then you could do it the following way:

1. Create web-item in Scriptrunner and choose "Do nothing you will use javascript to bind an action"

https://scriptrunner.adaptavist.com/5.2.4/jira/fragments/WebItem.html

2. Create your REST endpoint

https://scriptrunner.adaptavist.com/5.2.4/jira/rest-endpoints.html

3. Install web resource. You should add your custom javascript in which you would connect to the web item created in 1 and add needed by you search box and call your REST endpoint.

https://scriptrunner.adaptavist.com/5.2.4/jira/fragments/WebResource.html#_hiding_menu_button_using_javascript

 

I guess that would do the trick. But I never tried it and I do not have plans to try it.

Roberto L
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
January 8, 2018

@Alexey Matveev,

You where right, its hard to support.

I ended up using a static URL in an HTML document that re-directed over to site.

Thanks!

-Roberto

Deleted user
August 7, 2018

I am looking for exactly the same solution , can you let me know how you have implemented search

Yogesh Mude
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
May 3, 2020

Hi @Alexey Matveev 

I have added a button called send email using script fragments now whenever the user clicks on it it should open the user mailbox to send an email using mailto link.

Can you help me on this how can i call this mail to link on the button click.