Hello Team ,
I m really stuck with one of the requirement I have.
Using Jira server
I have created a scripted field with some requirement which is performing as expected .
Now i want that scripted field value to be used in behaviour or another scripted field .
But i m not getting any code or approach to fetch the scripted field value in another script .
Could you please help me achieving this as fast as possible.
Let me know if you need any input from my side
Calculated Script Fields do not show on transition screens (including create/edit), so I don't think that a behaviour can get to it, since it should only be working with fields on your current form.
You might try to use the 'underlyingIssue' binding variable and some more API to get to the value like this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
//underlyingIssue can be null, if you are on create screen; so we want to check if the issue already exists before trying to fetch a value from it
if (underlyingIssue != null) {
final String SCRIPT_FIELD_CUSTOMFIELD_ID = "customfield_11111"
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField customField = customFieldManager.getCustomFieldObject(SCRIPT_FIELD_CUSTOMFIELD_ID)
if (customField != null) {
//not sure which format this field uses, so using plain and generic Object as an example
Object customFieldValue = underlyingIssue.getCustomFieldValue(customField)
}
}
This should work in theory and you can then use the customFieldValue for wha'eva else you need.
Although, I am not IOO% sure if getting a customfieldvalue for a script field will actually get the value (I think it does though), or whether that value will always be accurate.
Alternatively you could reproduce what the script field is doing and insert it into your behaviour, although that sounds like code duplication, would try above first I think.
Lastly, as soon as you start doing any complicated behaviours, best to restrict the mapping to precisely where you need - things like these can junk up your instance real fast when executed too often.
Maybe it will be possible, to use this field as variable by using method below?
getFieldById("customfield_abc")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.