Forums

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

JIRA 7 Script Runner How to get the current (or self) scripted field name inside the script

Ramakrishnan Srinivasan
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 Leaders.
January 30, 2019

Hi,

 I have six custom fields to get the total of six pairs of other fields. So, the logic is same to get the total. So I want to write the condition where 

  • if the script is running inside a scripted field with name 'Total Field X', get the total of respective fields belonging to X
  • if the script is running inside a scripted field with name 'Total Field Y', get the total of respective fields belonging to Y
  • This will help me to maintain one script and load the same in six different fields

For this, inside the script I need to get the name of the (self) field where the script is running, like 'self name'

I tried searching through posts but mostly I found to get by already known name. 

Can anyone help me with this please?

Thanks in advance

regards

ramki

 

1 answer

1 accepted

0 votes
Answer accepted
Marc Minten (EVS)
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 Leaders.
January 31, 2019

I don't think you can get info about the custom field inside the script...

A solution might be

  1. create a script containing a class with a method that takes the name of the field as argument
  2. for each scripted custom field, call that method in that class with the right argument. Unfortunately, I think you can not call a method in a class you created yourself in an in-line script. So for each scripted custom field you should create a small script file that just calls the generic method in the class...
Ramakrishnan Srinivasan
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 Leaders.
January 31, 2019

Hi Marc Minten, Thank you for the response,

if I have to create such a generic method, it will reside where? unfortunately I am not the super admin having access to server and file paths, then currently I am not blocked by this, it is a little overhead to load the same script in six places but that looks easier option for me now,

with warm regards

ramki

Suggest an answer

Log in or Sign up to answer