Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,560,589
Community Members
 
Community Events
185
Community Groups

How to copy the values of child... And append that values to parent using jmwe

Edited

How to copy the values of child... And append that values to parent using jmwe groovy postfunction script ..

 

Please help me

1 answer

0 votes
David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jan 11, 2021

I assume you are on Jira Server / Data Center.

At what time do you want to copy the values of child issues to the parent issue? During a transition? Of the parent or the child? And by child/parent, do you mean sub-tasks/parent issue?

iam writing this groovy script in parent transition. As of now i am able to get the values into the parent . the appending part is not done .

unable to append  the values  from all the subtasks.

 

Please help me in this .

my script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.fields.CustomField

String Actionitems = "customfield_14003"
String completeditems = "customfield_14006"
String issueContextValue = issue.get("customfield_14003")
ApplicationUser loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
IssueManager issueManager = ComponentAccessor.issueManager
if(issue.get("summary") == "RBA Task for your group")
{return
}
else if(issue.get("summary") == "RBA Fullfillment Task for Desk Side")
{
def associates = issue.get(Actionitems)
MutableIssue parentIssueToUpdate = issueManager.getIssueObject(issue.parentObject.id)
String completeditemsParent = parentIssueToUpdate.get(completeditems)[0];
parentIssueToUpdate.setFieldValue(completeditems, completeditemsParent + "\nHardware:" + associates)
issueManager.updateIssue(loggedInUser, parentIssueToUpdate, EventDispatchOption.DO_NOT_DISPATCH, false)
}
else
{
def associates = issue.get(Actionitems)
MutableIssue parentIssueToUpdate = issueManager.getIssueObject(issue.parentObject.id)
String completeditemsParent = parentIssueToUpdate.get(completeditems)[0];
parentIssueToUpdate.setFieldValue(completeditems, completeditemsParent + "\nSoftware:" + associates)
issueManager.updateIssue(loggedInUser, parentIssueToUpdate, EventDispatchOption.DO_NOT_DISPATCH, false)
}

Hi @David Fischer _Appfire_ 

Now its working fine with append as well with below code. But the changelle is that there is null value also displaying in the output .Can you help me in this 

Script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.fields.CustomField

String Actionitems = "customfield_14003"
String completeditems = "customfield_14006"
String issueContextValue = issue.get("customfield_14003")
ApplicationUser loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
IssueManager issueManager = ComponentAccessor.issueManager
if(issue.get("summary") == "RBA Task for your group")
{return
}
else if(issue.get("summary") == "RBA Fullfillment Task for Desk Side")
{
def associates = issue.get(Actionitems)
MutableIssue parentIssueToUpdate = issueManager.getIssueObject(issue.parentObject.id)
String completeditemsParent = parentIssueToUpdate.get(completeditems)
parentIssueToUpdate.setFieldValue(completeditemsParent, completeditemsParent + "\nHardware:" + associates)
issueManager.updateIssue(loggedInUser, parentIssueToUpdate, EventDispatchOption.DO_NOT_DISPATCH, false)
}
else
{
def associates = issue.get(Actionitems)
MutableIssue parentIssueToUpdate = issueManager.getIssueObject(issue.parentObject.id)
String completeditemsParent = parentIssueToUpdate.get(completeditems)
parentIssueToUpdate.setFieldValue(completeditemsParent, completeditemsParent + "\nSoftware:" + associates)
issueManager.updateIssue(loggedInUser, parentIssueToUpdate, EventDispatchOption.DO_NOT_DISPATCH, false)
}

 

output:

Completed Items:null 
Software:Create account in Zoom portal
GSR for GitHub Access
GSR for Microsoft Storage Explorer
-- Completed
Software:Access to SharePoint Site; <ASG> [CONTRIBUTOR]
-- Completed

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jan 12, 2021

Hi @kiranmai genkolla ,

If I read your code properly, you are actually putting this code on a sub-task transition, not a parent transition, because "issue" represents a sub-task (otherwise you wouldn't be able to call issue.parentObject).

There is a much easier (and safer) way to accomplish the same thing. You can use a Set Field Value of Related Issues post-function with the following configuration:

  • Field: Completed Items
  • Which issue(s): Parent issue of the current sub-task
  • Value type: Groovy Expression
  • Value: this script
String Actionitems = "customfield_14003"
String completeditems = "customfield_14006"
if(issue.get("summary") == "RBA Task for your group" || issue.get(Actionitems) == null)
return null
if(issue.get("summary") == "RBA Fullfillment Task for Desk Side")
return relatedIssue.get(completeditems) + "\nHardware:" + issue.get(Actionitems))
return relatedIssue.get(completeditems) + "\nSoftware:" + issue.get(Actionitems))
  • Options: "Ignore empty values" checked 
Like kiranmai genkolla likes this

Hi @David Fischer _Appfire_ 

 

in one thing place ,
there is one drop down field in the parent .. based on that the values on it . i need to populate the fields on the close and on hold transition . this part was already done .

based on the values on the fields in the transition fields i need to append that fields in the parent issue .

Can you help me in this in code

David Fischer _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Feb 17, 2021

@kiranmai genkolla ,

I'm afraid I didn't quite get what you're trying to do. What do you mean by "append that fields in the parent issue"?

No David the above requirement is different one . But now I have achieved it .

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events