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,458,460
Community Members
 
Community Events
176
Community Groups

Scriptrunner custom template issue for picklist

Hi Folks,

I have crated a picklist custom filed with Groovy script by using below custom template, am able to list out all the required values in picklist but not able to save/hold the selected specific value from the list if user perform any operations like page refresh or filling other values picklist displaying default/first value from the list,

Please find the below custom template lnline code 

<p>
<select id="Planview Project Name">
$value
</select>
</p>  

May i know how we can save/hold the specific value from the picklist. Thankyou in advance.

1 answer

Hi @Sreenivas Narala

Could you provide a little more information, i.e. what have you used to configure your picklist? Is it Scripted Fields?

From the code that you have shared, it appears to be more of a javascript.

Could you please share the complete code you are currently using and a screenshot of your configuration so it can be reviewed?

Thank you and Kind regards,

Ram

Hi @Ram Kumar Aravindakshan _Adaptavist_ ,

Yes, I have configured Scripted Field with Groovy.

Based on my requirement want to display return values as a picklist/dropdown field and want to save selected value from the list at dashboard/issue creation.

i don't have any issue with source code and facing issue with custom template(picklist/Dropdown).

Below code for Advanced custom template return value(picklist/Dropdown).

<form>
<select id="Planview ProjectName">
<option selected disabled>--Select ProjectName--</option>
$value
</select>
<span class="overlay-icon throbber"></span>
<div class="save-options" tabindex="1"><button type="submit" class="aui-button submit" accesskey="s" title="Press Alt+s to submit this form" resolved=""><span class="aui-icon aui-icon-small aui-iconfont-success">Save</span></button><button type="cancel" class="aui-button cancel" accesskey="`" title="Press Alt+` to cancel" resolved=""><span class="aui-icon aui-icon-small aui-iconfont-close-dialog">Cancel</span></button></div>
</form>

 

Below is the source code to fetch the data by using API and list out json data by using for loop :-

import com.onresolve.scriptrunner.canned.jira.fields.model.PickerOption
import groovyx.net.http.ContentType
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.Method
import java.net.HttpURLConnection;
import net.sf.json.groovy.JsonSlurper
import net.sf.json.JSON;
import groovy.json.JsonBuilder
import java.util.TreeSet;

// Source code from below REST API

def get = "https://abc-planview-service.eu-gb.mybluemix.net/api/v2/projects?token=XXXXXXX".toURL().text
def json = new JsonSlurper().parseText(get)
def Name = json."name"
def result = ""
def sort = new TreeSet();

for (key_value in json) {
def Status_Value = key_value."status"
def BU_Value = key_value."bu"
def ProjectCategory_Value = key_value."projectCategory"

if (!((Status_Value == 'WBS20$CNCL') || (Status_Value == 'WBS20$CLOS') || (ProjectCategory_Value == "MVP Agile") || (BU_Value == "Property & Facilities Solutions")))
{
sort.add(key_value)
}
}

for (key_value in sort) {
result = result + "<option>"+key_value.name
}

return result

 

Please refer attached screenshots for reference and let me know if anything is neededScriptField_1.pngScriptField_2.pngCurrentOutput.pngExpectedOutput.JPG

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events