Forums

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

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

Павел Бородин
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 6, 2017

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
Nic Brough -Adaptavist-
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 6, 2017

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'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 6, 2017

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.

 

Nic Brough -Adaptavist-
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 7, 2017

>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