Forums

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

copy system field due to custom field while creating the current issue

Manideep Sadhu March 15, 2018

i need to copy the system filed value to the custom filed while creating the issue, could any one post the code to get the value from system field

 

1 answer

1 accepted

1 vote
Answer accepted
Aidan Derossett [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.
March 16, 2018

Hey there Manideep!

Usually you can get the value of a system field simply by calling methods directly on the Issue object. For instance, if you're dealing with a MutableIssue object, you have a ton of getter methods at your disposal:

issue.summary //gets you the summary
issue.description //gets you the description

//etc...

But it really depends on the context. What is your use-case? Why are you trying to get the system field values and where are you wanting to get them (i.e. in a post-function, behaviour, listener, etc...)?

Manideep Sadhu March 18, 2018

Hi Aidan Derossett [Adaptavist]

 Thanks for reply,

As i was new to this scriptrunner.this was one of our requirement

I want to get them in behaviour , i tried with issue .summary showing null but i was failed to get the issue object could you suggest me the way how to get the issue object

I you post the complete code that would help me a lot.

 

Thanks

Aidan Derossett [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.
March 22, 2018

Hey again,

For Behaviours the process is a little bit different. If you'd simply like to access a field that's on the form (like the create issue dialog or something), then we have a whole bunch of built in methods that you can use to do so: getFieldById, getFieldByName, etc... And with those you can get the summary field:

def summary = getFieldById("summary")
def summaryVal = summary.value
//etc...

 But, if you need the issue object itself, we also have built-in variables that you can use, like "underlyingIssue." That variable represents the current issue, so it's an Issue object and you could treat it as such, doing something like:

def summary = underlyingIssue.summary

If you want to know more about Behaviours or need to look at some examples, we have some great resources in our documentation

Does that answer your question? :D

Best, 

Aidan

Manideep Sadhu March 25, 2018

Hi Aidan Derossett [Adaptavist],

Thanks very very much, its works fine.

I had one more doubt this works when we are creating the task, but what about the already created ones. Do i need to write post functions , if we write post function how can we add custom fields programatically 

Thanks 

Manideep

Suggest an answer

Log in or Sign up to answer