How to get the custom field which approval list is based on?

I am trying to retrieve the customfield which the list of approver is based on so that I could modify the custom field value to re-populate the approval list but I check both EAP-4.0 and 3.x API there isn’t any method to retrieve the customfield.

Using ApprovalService, I am able to get the

  • list of approval
  • list of approver
    but I could not get the custom field which the list of approver is based on for a particular approval.

I understand the customfield’s ID is stored in AO_56464C_APPROVER.VALUE and I will be able to retrieve the custom field ID with the approval’s ID but is there any better way to access it via Atlassian Java API / REST?

I don’t think it is available. The approvals-plugin does not have an public interface.

It’s technically possible to get it from the workflow, as currently the data is stored against the workflow step properties. This script is a little inefficient, sorry, but illustrates the outcome fine:

def workflow = com.atlassian.jira.component.ComponentAccessor
    .workflowManager
    .getWorkflow('IT - Service Projects Change Management Workflow')

workflow.getLinkedStatusObjects()
        .collect{workflow.getLinkedStep(it)}
        .findAll{it.metaAttributes.containsKey('approval.active') && it.metaAttributes.get('approval.active')=='true'}
        .collectEntries{return [(workflow.getLinkedStatus(it).name):(it.metaAttributes.get('approval.insight.field.id'))]}

And the output of this is:
[Peer review / change manager approval:customfield_29805]

Which corresponds to this configuration:

And these properties: