Forums

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

Set Custom Filed value (grouppicker) if creator/report is in a specific group

Daniel Perdisatt
July 12, 2017

Hi,

I'm looking to create a script post function that will set a custom field(group picker) if the user is a member of a specfic group

Group Name = GroupA

Users in GroupA = A,B,C

CustomFiled = Participants (Group Picker (Single Group))

If the report/creator is a member of GroupA i want to set the Participants field to that group name so as that all users in that group can view the ticket. 

thanks,

Dan

 

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
May 2, 2023

You might need to extend your SIL using the SIL Groovy Connector.

Then use the native JAVA API to fetch the comments.

Here is an example of how the SIL Groovy Connector can call a groovy script.

https://appfire.atlassian.net/wiki/spaces/PSJ/pages/15488333/Passing+Values+Between+SIL+and+Groovy

PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
May 2, 2023

Here is a sample groovy script to return all the comments from an object given its key:

 

import com.atlassian.jira.component.ComponentAccessor

def objectKey = "{{objectKey}}"
def classLoader = ComponentAccessor.pluginAccessor.classLoader
def ObjectFacadeClass = classLoader.findClass('com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade')
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ObjectFacadeClass)
def object = objectFacade.loadObjectBean(objectKey)
def comments = objectFacade.findCommentBeans(object.id)
comments*.comment

Use the method mentioned above to replace {{objectKey}} with the actual key of the object.

I'm more of a groovy/scriptrunner person myself. So I'm not familiar with SIL and how you might be able to grab additional content from each comment or how you might pass a more complex structure from the groovy script to the SIL engine.

Like Matt Donnelly likes this
Georg
May 3, 2023

I love you man, it works!!
Can you provide useful documentations on your opinion to understand code above

PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
May 3, 2023

The starting point for using groovy with Insight is the 

Assets app development > Groovy scripting page

And how each Insight/Asset classes might be used can be found in the JavaDocs

For example, here is the JavaDoc for ObjectFacade and the Javadoc for ComentBean.

TAGS
AUG Leaders

Atlassian Community Events