It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Script runner - access fields from Profields plugin

Hello

Is it possible to accessProfields plugin's values through ScriptRunner?

For.e.g. I'd like to get profields values from custom REST endpoint.

When I am importing profields classes, it shows me an error

"Unable to resolve class com.deiser.jira........" (see attached screenshot)

 

script runner and profields.png

Thank you in advance!

Fyodor

2 answers

1 accepted

0 votes
Answer accepted

Hi Fyodor,

It's a pleasure to hear from you again :)

You can find the solution in this post: https://scriptrunner.adaptavist.com/latest/jira/scripting-other-plugins.html

In this case, the code gets the value of the status field in a project:

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.deiser.jira.profields.api.field.FieldService
import com.deiser.jira.profields.api.value.ValueService
import com.deiser.jira.profields.api.field.status.StatusField
import com.atlassian.jira.issue.Issue

@WithPlugin("com.deiser.jira.profields")

Issue issue = ComponentAccessor.issueManager.getIssueByCurrentKey("SCRUM-7")

def valueService = ComponentAccessor.getOSGiComponentInstanceOfType(ValueService.class)
def fieldService = ComponentAccessor.getOSGiComponentInstanceOfType(FieldService.class)

def statusField = fieldService.get(9) //ID of field Status

return valueService.getValue(issue.projectObject,(StatusField) statusField)

 

You can find all the API info of versión 5.5.4: http://profields.javadoc.deiser.com/5.5.4/

Regards,

Adrián.

Hello Adrian

Thank you for advice.

 

Fyodor

Hi Adrian,

I am using prifields api in one of my custom JIRA plugin.

I have implemented in a similar fashion as per your post bet getting below Error.

valueService.getValue(issue.projectObject,(StatusField) statusField)

 Error Log :

java.lang.ClassNotFoundException:com.deiser.jira.profields.api.field.status.StatusField

not found by com.org.jira.plugin.synch-onejira-plugin [276]

at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)

at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)

at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)

at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

at com.org.jira.plugin.ojira.wf.postfunction.SetChannelFieldPostfunction.calculateChannelFieldValue(SetChannelFieldPostfunction.java:138)

Hi @Kiranped,

 

What version of Profields plugin do you have installed?

 

Cheers,

Adrián.

Profields 5.3.0 and jira 7.6.0

Hi @Kiranped,

 

Can you update Profields plugin to the last version and do the same test?

 

Cheers,

Adrián.

@Adrián Plaza _DEISER_,

 

I have tried with 5.6.3 version and JIRA 7.6 version. I am facing the same problem.

Profield Type: Select List (single choice)

I am using ListField

 

private Field getPartnerVisibleProField(){

List<Field> fields = fieldService.get();

for (Field field : fields){

if ("Field_Name".equals(field.getName())){

return field;

}

return null;

}

valueService.getValue(issue.projectObject,(ListField) getPartnerVisibleProField()) // 

java.lang.NullPointerException

 

*********************************StatusField case******************************

if I typecast to (StatusField)getPartnerVisibleProField(), getting null object but I have a value updated

Muy buenas Adrian,

Estoy evaluando el plugin y necesito saber si puedo cambiar un campo de tipo status en una postfuntion de script runner.

Por ejemplo:

Al ejecutar un bloqueo de una tarea que el campo status del proyecto cambie a bloqueado. ¿tienes un ejemplo para orientarme?

 

Un saludo.

I am evaluating the plugin and I need to know if I can change a field of type status in a postfuntion of script runner. For example: When executing a block of a task, the status field of the project changes to blocked. Do you have an example to guide me? A greeting.

@fjodors - Is this issue resolved. I am also facing the same issue.

Hi

Yes, you need to add @WithPlugin("com.deiser.jira.profields") command, then you can use profields methods and classes.

See related issues

Hey, I have done this through REST End Point and it is working. But while I am executing same script via custom script applied on post function of the jira workflow. It shows the error.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you