Concatenate two attributes in an automation

lemoi January 13, 2022

screenshot.png

 

Unlike the following thread: https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Set-Insight-Automation-to-Concatenate-two-Attributes-when-an/qaq-p/1489152 when I'm trying to save my automation I have the following error :


Error

An error occurred when updating the rule. Please try again and report the problem if it continues.

 

My goal is to standardize by automation all the name of the object type "License (per user)" by concatening the two value : License and Username.

 

Environment

Jira Service Management 4.20.1 on premises

 

I'd appreciate any help, thanks in advance !

3 answers

1 accepted

0 votes
Answer accepted
lemoi February 1, 2022

I finally resolved my issue, I created a new automation as follow : 

Screenshot 2022-02-01 182100.png

and created the following Groovy script using ScriptRunner plugins:


import com.atlassian.jira.component.ComponentAccessor;

Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade");
Class objectTypeFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeFacade");

def objectTypeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectTypeFacadeClass);
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade"));
def objectTypeAttributeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeAttributeFacade"));
def objectAttributeBeanFactory = ComponentAccessor.getOSGiComponentInstanceOfType(ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.services.model.factory.ObjectAttributeBeanFactory"));

def objectTypeAttributeBean = objectTypeAttributeFacade.loadObjectTypeAttributeBean(1919).createMutable() //Get Name object based on ID attribute

//log.info(object.getObjectAttributeBeans().toString());

def attributes = object.getObjectAttributeBeans();
attributes.each{attribute ->
def type;
try {
type = objectTypeAttributeFacade.loadObjectTypeAttributeBean(attribute.getObjectTypeAttributeId());
} catch (Exception ee) {
log.warn("Could not load objectdue to validation exception:" + ee.getMessage());
}

if (type != null && "Software".equals(type.getName())){
license = objectFacade.loadObjectBean(attribute.getObjectAttributeValueBeans()[0].getValue().intValue()).getName();
}
if (type != null && "Username".equals(type.getName())){
username = attribute.getObjectAttributeValueBeans()[0].getValue();
}
}

def newname = username + ' - ' + license ;


/* Create the new attribute bean based on the value */
def newObjectAttributeBean = objectAttributeBeanFactory.createObjectAttributeBeanForObject(object, objectTypeAttributeBean, newname);
/* Load the attribute bean */
def objectAttributeBean = objectFacade.loadObjectAttributeBean(object.getId(), objectTypeAttributeBean.getId());
if (objectAttributeBean != null) {
/* If attribute exist reuse the old id for the new attribute */
newObjectAttributeBean.setId(objectAttributeBean.getId());
}
/* Store the object attribute into Insight. */
try {
objectTypeAttributeBean = objectFacade.storeObjectAttributeBean(newObjectAttributeBean);
} catch (Exception vie) {
log.warn("Could not update object attribute due to validation exception:" + vie.getMessage());
}

Hope it can help someone :).

Topic resolved on my end.

0 votes
lemoi January 16, 2022

I tried opening the Developer tools to troubleshoot the issueScreenshot 2022-01-17 135205.png

The last cookie have the following information : "The cookie was blocked because neither did the request URL's domain exactly match the cookie's domain, nor was the request URL's domain a subdomain of the cookie's Domain attribute value"

As I was in incognito mode to login as administrator, I tried to follow that link solution https://confluence.atlassian.com/jirakb/where-are-the-insight-logs-for-data-center-installations-1040617518.html 

 

Unsuccessful so far.

0 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 13, 2022

Hi Yannick,

I don't see any problem with the syntax, but I don't use Jira Server either. I do know that would probably work if you were using Automation for Jira (there's a free and paid add-on) as I do that with Jira Cloud. 

lemoi January 16, 2022

Thanks for your answer, I'm using the free Automation included in Insight.

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 17, 2022

I would suggest creating your rule using automation for Jira instead of the built in JWM automation. 

Like lemoi likes this
lemoi January 17, 2022

I checked Automation and Project Automation, both of them do not offer option related to Insight, neither in condition nor action offered. I guess that's a feature only available for Jira Cloud ?Screenshot 2022-01-18 152429.png

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 18, 2022

Looks like that is the case. Are you using the Paid Automation Pro versioin? 

lemoi January 18, 2022

I'm using the Automation for Jira version 7.4.0Screenshot 2022-01-19 134716.png

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 19, 2022

Yeah, looks like it is not possible.  :-(

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events