Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Script approver field issue

Sravan kumar July 22, 2025

Hi Team,
Once the user selects Jira project in jira project picker field and then the approver field will be going to set by the Project lead which is happening by the restAPI, but now days the ticket is created without adding the approver and which is mandatory this is happening only for few tickets, Can you please help us in providing the solution for this.


Thanks,
Sravan kumar. 

1 answer

0 votes
Fabio Racobaldo _Catworkx_
Community Champion
July 23, 2025

Hi @Sravan kumar and welcome,

please could you provide post function information that put Approver on ticket creation?

Fabio

Sravan kumar July 23, 2025

Hi @Fabio Racobaldo _Catworkx_ ,
Thank you so much for supporting on this request.
Please find the script

def currentField = getFieldById(getFieldChanged()).getValue().toString()

def approverfield = getFieldByName('Approvers')

if (currentField != "null") {

    def leadvalue = ComponentAccessor.getProjectManager().getProjectObjByKey(currentField).getProjectLead().getName().toString()
    //value will be searched on user picker field on the basic of Username of project lead
   
    approverfield.setFormValue(leadvalue)

    approverfield.setHidden(true)
}
else {
    return
}
Please let me know if any information is needed.
Fabio Racobaldo _Catworkx_
Community Champion
July 24, 2025

Hi @Sravan kumar ,

this seems to be a behaviour and not a post function (please confirm). If so and Approvers is a single user picker try the following code

import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.component.ComponentAccessor

def approverfield = getFieldByName('Approvers')

def projectField = getFieldById(getFieldChanged())

def project = projectField.getValue();

String projectKey = project!=null?project.toString().replaceAll("Project: ",""):null;

if(projectKey!=null){

    ApplicationUser leadvalue = ComponentAccessor.getProjectManager().getProjectObjByKey(projectKey).getLead();

    approverfield.setFormValue(leadvalue);

    approverfield.setReadOnly(true);

}
Let me know,
Fabio

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events