calculates text field, script too long

Hi all,

I'm creating a new business project in JIRA, each issue has the following fields:

  • supplier code 
  • supplier description

I wuold like automatically compile the supplier description based on the supplier code that is a text free field.

I tried to use the calculated text field, but the problem is that I have more than 4000 possible supplier and my script become too long and when i insert it in the description i receive an error...

Do you know a way to solve this problem?

Thank you!

Simona

 

6 answers

This widget could not be displayed.

How does your code looks like? Have you tried any other way of displaying this like the Cascading Select Custom field? 4000 seems a very long list, are all those active?

This widget could not be displayed.
Vasiliy Zverev Community Champion Dec 28, 2015

As I understand you need to get description for any of 4000 basing on it's code. Is is right?

This widget could not be displayed.

Yes, it is correct! I need the description for each supplier code

<!-- @@Formula:
String suppliercode= issue.get("customfield_12462");

if (suppliercode.equals( "001" )) return "supplier 1";
if (suppliercode.equals( "002" )) return "supplier 2";
if (suppliercode.equals( "003" )) return "supplier 3";

etc...

 

-->

Can you help me?

Thank you!

Simona

This widget could not be displayed.
Vasiliy Zverev Community Champion Dec 28, 2015

I think you should use Map collection in this case. To make code more readable it better to put map filling into a function. Here is a code example how to do it, tune it to your needs:

import java.util.Map

Map&lt;String, String&gt; suppliersMap = new HashMap&lt;&gt;();

initiateMap(suppliersMap);

return suppliersMap.get("code " + 2053)

public initiateMap(Map&lt;String, String&gt; _map ) {
    for(int iSupl = 0; iSupl &lt; 4000; ++iSupl)
    _map.put("code " + iSupl, "desription " + iSupl);
}
This widget could not be displayed.

sorry I wrote an example not inserting the correct values...

<!-- @@Formula:
String suppliercode= issue.get("customfield_12462");

if (suppliercode.equals( "001" )) return "Pippo";
if (suppliercode.equals( "AB4" )) return "Pluto";
if (suppliercode.equals( "C73" )) return "De cicco";

-->

so I don't think I can use an iterative code, but I am not so expert,... 

Simona

This widget could not be displayed.

Sorry for the delay in the answer...yes , its are 4000 and all active... sad

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 06, 2018 in Jira Service Desk

A is for Activate: Share your top Jira Service Desk onboarding tips for new users!

Hi, everyone! Molly here from the Jira Service Desk Product Marketing Team :).  In the spirit of this month's  august-challenge, we're sourcing stories of Jira Service Desk activation fro...

528 views 23 15
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you