Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Add component that matches custom field value via automation

Yehoshua Silberstein August 21, 2022

I am using a custom field for customer name (party name) and have components for certain high value customers. I am trying to write an automation rule that checks the value in party name field to see if there is a component that contains that name and to then add that component to the issue and also update the party name field to match the added component. 

I am able to use advanced compare to find the components as shown in the screenshot below. However, the screenshot below only works if there is a component that equals the party name field (since it's putting the party name value in the components field).

How do I add the component that was located through the compare function and add it even if it only contains but doesn't exactly match the party name field?

 

Screen Shot 2022-08-21 at 3.48.38 PM.png 

1 answer

1 accepted

2 votes
Answer accepted
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 22, 2022

Hi @Yehoshua Silberstein  I think {{project.components.name}} is not a correct way of getting project Components. Kindly check this post for getting project components :- 

https://community.atlassian.com/t5/Jira-Software-questions/Jira-automation-get-all-project-components/qaq-p/1854126

@Bill Sheboy  Kindly suggest the correct way of getting project component/s.

Thanks

V.Y

Bill Sheboy
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 Leaders.
August 22, 2022

Hi @Yehoshua Silberstein 

Pausing for a moment: what problem are you trying to solve by storing the same information in two different fields: a custom field and in a component?  For example, is this to support reporting somehow?

Regarding your questions...

As @Vikrant Yadav noted, you may get all of the available components for the project by calling the REST API from the rule.  

Yet you noted this:

How do I add the component that was located through the compare function and add it even if it only contains but doesn't exactly match the party name field?

What does "doesn't exactly match" mean to you?  I believe you will need to define your criteria for a partial match, and then use that to find a match in the results from the REST API call.

Kind regards,
Bill

Yehoshua Silberstein August 22, 2022

@Bill Sheboy yes it is to support reporting. We are using components in a helpdesk and surfacing the {{issue.party name}} field on the request form. 

Current behavior is that any value can be added to the party name field, but there are only components for certain high value customers. This allows anyone who raises a request in our service desk to type in any value for the party name and for us to track and report on from within the service desk all requests for those specific high value customers (party name is plain text field whereas components are a defined list).

To @Vikrant Yadav's point, the query that I've built - {{project.components.name}} contains {{issue.party name}} already partially works but only as if it was written as  {{project.components.name}} equals {{issue.party name}}.

Without relying on REST API, it checks whether there is a component in the project that contains the words from {{issue.party name}} field. For example, if there is a component called "Joe's Widgets International" and the requester entered "Joe's Widgets" it checks if there is a component that includes the words "Joe's Widgets." The problem is in the second step of adding the component to the issue. Since the rule doesn't create new components, it tries to add the component with the value of {{issue.party name}} and it can only do that if the component name exactly matches the value in the text field. 

So the rule ends up only working as intended if the requester entered for {{issue.party name}} "Joe's Widgets International" (since that matches component exactly).

What I want it to do is to add the component that it located during the query and add it even if the component contains more words than the text in {{issue.party name}} field.

I hope that makes things clearer and if possible I would want to avoid using REST API since that is slightly out of my area of expertise.

Bill Sheboy
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 Leaders.
August 22, 2022

Thanks for clarifying your use case...

Short answer: I do not believe partial matching is possible without calling the REST API.

Longer answer:

Automation rules have triggers and actions that can access issues, versions, sprints, etc.  They cannot access components not already associated to an issue except while comparing/editing issues or calling the REST API.

As noted earlier, you could call the REST API to gather all of the components and then use a regular expression for your partial match, and then select that component for addition to the issue.

If you want to try this approach, here are some examples and references:

Like # people like this
Yehoshua Silberstein August 22, 2022

Thanks for the additional clarification. I will work with someone to configure the REST API for our rule to allow it to work properly.

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events