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

How do I run a script when the value in the customfield?

Hello.
How do I run a script when the value in the customfield, if the value to which the change is unknown to me.
Is that possible? Thank you in advance.

1 answer

0 votes

Could you give us more detail on:

  • when this should run.  "a value in a field" does not tell us when you want to do it.  (Think of it this way - I wrote "dave" on a note.  My note has a value of "dave".  Do I run a script when I write the note, when I throw it away, or every second that "dave" is on it?)
  • You say "if the value to which the change is unknown".  That's not an English clause, and hence makes no sense.  At a guess, you are trying to say that you want to update a custom field with some data, but the clause implies that you do not know the data.  This will not work.  Imagine that you hire someone to paint a wall.  They come to your house and ask "what colour do you want the wall?".  When you say "I don't know", they cannot do it.  That's what you have done to us here.

I'll try to explain.
I have a drop-down list, the script should be triggered when any item.

That's how I'm trying to implement it:

log.setLevel(org.apache.log4j.Level.INFO)
log.info("Start");

IssueManager issueManager = ComponentAccessor.getIssueManager();

def change = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "customfield_10200"}
if (!change) {
log.info ("Developer changed" + change.oldstring )

log.info ("Developer changed" + cchange.newstring )
}

 

But the mistake: java.lang.NullPointerException: Cannot get property 'oldstring' on null object

I'm doing something wrong, but I can not figure out what it was.

 

>the script should be triggered when any item

when any item what?

Your code is from a listener though, and it needs a tweak if I'm understanding what it's for.  Try

change.get("oldstring")

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

1,216 views 8 1
Join discussion

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