I am trying to create some scripted fields using the Profields add-on and I have a couple of questions.
1) I'd like to be able to create one Profields scripted field that's usable in multiple projects. For example, let's say I have a scripted field called "Planned Hours," which adds up all of that project's issue's Original Estimates. I want to be able to use this field for 10 different projects. However, I'm still relatively to groovy scripting and I don't know how to pull the current project's key for use in the script. Is there a way to do this? The only way I know to do this is to create a Profields scripted field that is suited to each project, but that isn't very ideal to our situation since we eventually have many, many projects in our JIRA instance.
2) I also want to be able to create a scripted field that can pull the values of other Profields scripted fields within that same project to calculate new scripted fields. For example, I'd like to create two scripted fields called "Total Time Spent" and "Total Time Remaining," then add both of those values together in a third field called "Estimate at Completion." Is this possible in Profields? I'm trying to figure that out using the Java API from Profields, but I'm not having luck finding the right packages/methods.
Any help is appreciated - thanks so much!
Community moderators have prevented the ability to post new answers.
Found some answers myself, so I'm updating in case anyone else has the same questions!
1) You can get the issue's in a project using this snippet:
def projectId = project.getId() def issueIds = issueManager.getIssueIdsForProject(projectId) def issues = issueManager.getIssueObjects(issueIds)
2) You can use this snippet to get an existing Profields field and its value. No need for any imports since the plugin makes this available to you already.
// fieldId is the ID of the Profields field def field = fieldService.get(fieldId) // NOTE: value is pulled as String def value = field.getValueInProject(projectId)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.