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 vote

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

192 views 0 6
Read article

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