Hi
I use the Projectrack for project tracking in Jira, In this plugin, there is a field called project status, can you guide me on how to get the value of this field with the Script Runner?
Footnote: I have attached a part of the code related to the API between these two programs in the form of a photo
What the name of the field you want to get ?
Have you try something like this ?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.Project
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.deiser.jira.profields.api.project.Project
import com.deiser.jira.profields.api.field
import com.deiser.jira.profields.api.field.status
import com.deiser.jira.profields.api.value.ValueService
def Project_Id = project?.id
def Project_Key = Project.getKey()
def project = ComponentAccessor.getProjectManager().getProjectByCurrentKey(Project_Key)
log.warn("Project: $Project_Key : $Project_Id")
@WithPlugin("com.deiser.jira.profields")
@PluginModule
ValueService valueService
@PluginModule
FieldService fieldService
def statusField = fieldService.getWithIgnoreCase(<REPLACEWITHFIELDNAME>)
log.error(statusField)
if(statusField.size() == 1){
def project_Status = valueService.getValue(project,statusField.first())
if(project_Status.getText() == "Closed")
{
String permissionScheme = "Closed"
ComponentAccessor.getPermissionSchemeManager().removeSchemesFromProject(project)
ComponentAccessor.getPermissionSchemeManager().addSchemeToProject(project, ComponentAccessor.getPermissionSchemeManager().getSchemeObject(permissionScheme))
}
}
many thanks for your help.
First, regarding your question, I must say that the name of the field is "project status". I want to use this script for automation, which at the beginning of the automation is supposed to check if the project status field changes, this script will be executed (that is, it has nothing to do with the issue and works directly with the project). How do I get the project key in the script? Because this automation is supposed to be applied to all projects and find each one that changed, but because it is an automatic process, I have to say in the script that I saw that it was the project that changed, give me the project key :) And finally, thanks for the code , yes it works :*)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Join the largest European gathering of the Atlassian Community and reimagine what’s possible when great teams and transformative technology come together. Plus, grab your Super Fan ticket now and save over €1,000 on your pass before prices rise on 3 June.
Register nowOnline 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.