Forums

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

JMWE - I need help with my scripts

Cesar Duran January 23, 2024

We are migrating to the Cloud and I need help with these post-fucntion scripts that are currently working on JMWE Server. The scripts were written by the legend David Fischer and I'm hopping he can read this, if not, any help will be much appreciated.

 

Script #1: it looks for the last number in a dropdown and adds one more to use it in the second script:

def issues = jqlSearch ('"URD ID Sequence (OJSBOX)" is not EMPTY ORDER BY "URD ID Sequence (OJSBOX)" DESC',1)
def max = 1
if (issues.size() == 1)
max = issues.first().get("customfield_18018") + 1
return max

 

Script #2: this other script will be adding a string to a text field, it will get the text in parentesis in the Component, the last 16 characters in the fix version and it will add at the end the number collected in the fisrt script: 

import org.apache.commons.lang.StringUtils;

if(issue.get("components")){

def comName = issue.get("components").first().name

def Version = issue.getAsString("fixVersions").substring(16)
return "${Version}-${StringUtils.substringBetween(comName, "(", ")")}-${String.format("%05.0f",issue.get("customfield_18018"))}"
}import org.apache.commons.lang.StringUtils;

if(issue.get("components")){

def comName = issue.get("components").first().name

def Version = issue.getAsString("fixVersions").substring(16)

return "${Version}-${StringUtils.substringBetween(comName, "(", ")")}-${String.format("%05.0f",issue.get("customfield_18018"))}"
}

 

***Example Data***

Component/s: AI ML - Intelligent MedDRA Coding (IMC)

Fix Version/s: LifeSphere MultiVigilance 2022.2.3.0

Correlative Number: 00007

An this is the URD ID we are getting: 2022.2.3.0-IMC-00007

 

Thanks in advance for your help.

3 answers

2 accepted

1 vote
Answer accepted
David Fischer
Community Champion
January 23, 2024

Hi @Cesar Duran ,

for the first script, something like this should work:

{% set issues = '"URD ID Sequence (OJSBOX)" is not EMPTY ORDER BY "URD ID Sequence (OJSBOX)" DESC' | searchIssues(maxResults=1, fields="customfield_18018") %}
{% if issues %}
{{issues[0].fields.customfield_18018 + 1}}
{%else%}
1
{%endif%}
Cesar Duran January 28, 2024

Thanks David, this works like a charm.

0 votes
Answer accepted
David Fischer
Community Champion
January 23, 2024

Hi again @Cesar Duran 

for the second script, try something like:

{%set comp = issue.fields.components | first | field("name") %}
{%if comp%}
{{issue.fields.fixVersions[0].name.substring(16)}}-{{comp.match(r/^.*\((.*)\).*$/)[1]}}-{{(issue.fields.customfield_18018 | string).padStart(5,0)}}
{%endif%}
Cesar Duran January 28, 2024

And this other part too, thanks again sir.

0 votes
Cesar Duran January 23, 2024

Let me add a couple of screenshots of the postfunctions in Jira Server:

image.pngimage.png

Suggest an answer

Log in or Sign up to answer