Hi,
I have created an scripted file "FamilyID" that have to check if itself has a previous value. When I reference to the scripted field I received a: java.lang.StackOverflowError
This is my code:
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField FamilyID = customFieldManager.getCustomFieldObjectByName("FamilyID")
return FamilyID.getValue(issue)
Is it possible to reference for the same custom field into an scripted field?
Regards
You get a stack overflow because your code calls out to get the field which runs your code that calls out to get the field which runs your code that calls out to get the field...
That recursion stops when the process runs out of working space in which to repeat itself.
What you're doing sounds like nonsense to me - a scripted field is there to work something out to display to the user. By definition, if it has a previous value, it has changed, so it's always going to be trying to work out something. But, scripted fields don't have a history because they are not data, they're a calculation.
You need to think about what you're really trying to do - I suspect you really mean that you want to look an issue and work out if something on the issue has changed in a way that you need to pull out.
Hi Nic,
First of all, thanks for your answer. I understand what you explain in your post.
What I am trying to develop is an scripted field that runs when a ticket is cloned. Then the key of the source ticket is copy into a scripted field in the cloned ticket. But if the cloned ticket is cloned again the scripted field gets the source key.
For example:
Ticket1 (FamilyID: null) ---> Clone ---> Ticket 2 (FamilyID: Ticket 1) ----> Clone ----> Ticket 3 (FamilyID: Ticket1)
I share with you the full code:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
List <IssueLink> allOutIssueLink = ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId());
for (Iterator <IssueLink> outIterator = allOutIssueLink.iterator(); outIterator.hasNext();) {
IssueLink issueLink = (IssueLink) outIterator.next();
String linkType = issueLink.getIssueLinkType().getName();
if (linkType == "Cloners"){
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField FamilyID = customFieldManager.getCustomFieldObjectByName("FamilyID")
String FamilyIDValue = issueLink.getDestinationObject().getCustomFieldValue(FamilyID);
Boolean IsSubTask = issueLink.getDestinationObject().isSubTask();
if (IsSubTask == false){
if ( FamilyIDValue?.trim ()){
String key = issueLink.getDestinationObject().getKey();
return key
}else{
return FamilyIDValue
}
}
}
}
This is not working fine. The FamilyIDValue is always empty.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>What I am trying to develop is an scripted field that runs when a ticket is cloned.
Scripted fields show a calculated value, they don't hold data. They don't "run" during events, the easiest way to think of them is that they calculate the value shown when an issue is indexed.
That said, I can't see that your code is wrong, unless it's not finding the link types or the "family id" field (as long as the family id field is NOT the scripted field itself)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes Nic, that is it. The FamilyID is the scripted field.
So that code is not valid for resolved my problem.
Thanks for the info!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To sum up, it is possible to call an scripted field from an scripted field in groovy?
Thanks
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.