The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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.
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.
This month the spotlight is on AppLiger. We caught up with Pavel Pavlovsky, CEO and Product Manager, to learn how the company started and what fuels the team's creativity. Atlassian:...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.