Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Retrieve value of numeric Custom field in SR Behaviors Edited

Hi!

I'm having trouble with server-side script in SR Behaviors. Any help would be greatly appreciated.

 

Requirement:

  • After value added to Numeric Custom field, check expression
  • If the value doesn't match local number format (russian), try simple transformations to rectify most regular mistakes (usual for copy-paste):
    • Delete spaces (thousands separators, extra symbols at the start or the end)
    • Replace "." with ","

Local number format:

  • Correct value: ####,## (i.e. 150345,53)  (please note the comma, it plays a role)

 

Code:

def revField = getFieldByName("My numeric CF")
def revFieldCurValue = revField.getValue().toString()

if (!revFieldCurValue.matches("[0-9]*(|[0-9]*,[0-9]{2})") && !revFieldCurValue.matches("[0-9]*(|[0-9]*,[0-9]{1})") && !revFieldCurValue.matches("[0-9]*")) {
log.warn("Fire!")
def revFieldNewValue = revFieldCurValue.replace(" ", "")
revFieldNewValue = revFieldNewValue.replace(".", ",")
revField.setFormValue(Long.valueOf(revFieldNewValue))
}

 

The problem is that <getValue()> returns "null" in my instance.

Even more frustrating is that "null" returns even if the value is correct, but it has decimals (which separated by comma)!

For example, correct format of value "10000,00" gets null. But "10000" gets "10000.0".

 

Is there a way to retrieve value initially with transformation from local format to long or to string?

Or may be there is a completely different way to achieve the same thing (requirement-wise)?

1 answer

Hi @Alex Trebek,

Currently, the format of the Number Field that you are trying to configure is not supported by Jira; hence it's not doable in ScriptRunner.

Please visit this Atlassian Jira Ticket for more information.

Thank you and Kind Regards,

Ram

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

JSM June ask me anything (AMA)

Hello Community members! We’re wrapping up the end of JSM June with an Ask Me Anything (AMA) with the Jira Service Management product team. This is your chance to ask all your ITSM questions to o...

120 views 7 10
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you