Team,
Using below script the summary field is set with insight object Key so I want to set summary with object name instead of Key.
{code}
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.SUMMARY
@BaseScript FieldBehaviours fieldBehaviours
def part = getFieldByName("Number").value
def summary = getFieldById("summary")
summary.setFormValue(" Test for ${part}")
{code}
I feel like in behaviour it always returns string value which is object key, not the stored object itself. Guess, the way of solving it might be like this:
import com.atlassian.jira.component.ComponentAccessor
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade")
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass)
def insightKey = getFieldByName("Number").value
def summary = getFieldById("summary")
def part = objectFacade.loadObjectBean(insightKey)?.label
summary.setFormValue(" Test for ${part}")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you actually try saving and running it?
Don't pay attention to static type checking.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thank you @Ilya Turov , its working fine.
thanks a lot. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Can I use similar code to return the objecttype of an object?
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Anna Protopapa
I didn't test it, but looking at javadoc something along those line might work
import com.atlassian.jira.component.ComponentAccessor
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade")
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass)
Class objectTypeFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeFacade")
def objectTypeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectTypeFacadeClass)
def objectTypeKey = getFieldByName("Number").value
def summary = getFieldById("summary")
def objectTypeId = objectFacade.loadObjectBean(insightKey)?.objectTypeId
def objectTypeName = objectTypeFacade.loadObjectTypeBean(objectTypeId)?.name
summary.setFormValue(" Test for ${objectTypeName}")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.