Profields API 4.10 - get value of specific Profields List Field in specific project


I am trying to get value of specific Profields List Field in specific project.

My code is:

def ProfieldsValueService = ComponentAccessor.getOSGiComponentInstanceOfType(ProjectValueService.class);
def ProfieldsFieldService = ComponentAccessor.getOSGiComponentInstanceOfType(FieldService.class);

//field ID in profield scheme
def ClientFieldID=1;
ProfieldsField ClientFieldObj = ProfieldsFieldService.get(ClientFieldID);

    Object ClientFieldValueObj=ClientFieldObj.getValueInProject(projObj);

catch(def exception){
    ClientFieldValueStr='***unable to get Customer for issue '+iss.key;

Variable ClientFieldValueStr returns me "[com.deiser.jira.profields.projectvalue.SourceValueImpl@23f7df76]" instead of field value.
From API documentation ( it seems I should use SourceValue/SourceService interfaces, but I don't understand how....

Could you help me?

Thank you!


1 answer

1 accepted

0 votes
Answer accepted

Hi Fyodor

Because the field is a ListField, the method you are using is like:

List<SourceValue> getValueInProject(Project project)

It returns a list of values (SourceValue) that has three properties: key, parentKey and value.

Then, you need to iterate over the list and get the value of each item. If your field is a simple list, you only need to get the first element and then its value.

This is your code modified:

import com.atlassian.jira.component.ComponentAccessor
import com.deiser.jira.profields.api.projectvalue.ProjectValueService
import com.deiser.jira.profields.api.field.FieldService
import com.deiser.jira.profields.api.field.ProfieldsField

def profieldsValueService = ComponentAccessor.getOSGiComponentInstanceOfType(ProjectValueService.class);
def profieldsFieldService = ComponentAccessor.getOSGiComponentInstanceOfType(FieldService.class);

// Project Key
def projectKey="ONE"
// Field Id
def fieldId=1

def value=null
def listField = profieldsFieldService.get(fieldId)
def project = ComponentAccessor.projectManager.getProjectObjByKey(projectKey)
def clientValue = listField.getValueInProject(project)
value = clientValue[0].value
catch(def exception){
value = '***unable to get Customer for issue '+iss.key;

return value

Hope it helps.


And sorry for the delay in answer, I didn't see that the question was wrote in March

Hello Carlos

We already updated our profield module till 5 version, this new version has more usable API and I was able to get all values.

Anyway, thank you for reply, it will be helpful for older jira/profield instances.


Hi Fyodor,

May see the sample script you sued to get the field values?


Try this

import com.deiser.jira.profields.api.field.FieldService
import com.deiser.jira.profields.api.field.Field
import com.deiser.jira.profields.api.field.list.ListField
import com.deiser.jira.profields.api.value.ValueService

def valueService = ComponentAccessor.getOSGiComponentInstanceOfType(ValueService.class)
def fieldService = ComponentAccessor.getOSGiComponentInstanceOfType(FieldService.class)
def CustomerFieldID = 11;
Field myListField = fieldService.get(CustomerFieldID);
def ClientFieldValueStr = valueService.getValue(projObj,(ListField) myListField).toString();

Hi Fyodor,

Thanks, I'll test it now.


Hi Fyodor,

It works! 
Thanks a lot!


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Opsgenie

Getting the Most out of Atlassian and Opsgenie Together

We’re excited to invite you to this action-packed webinar where we will demonstrate how to integrate Opsgenie’s powerful alerting and on-call management tools with your entire Atlassian stack. Mar...

63 views 0 0
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you