A4J - Limiting the visibility of a multi-project rule with a manual trigger to one project

Dave Furlani
Contributor
April 9, 2024

We have a business layer project where we track all design tasks for our Product Owners. The output of those Tasks will be 1 or more Stories in 1 or more system layer projects (one per code base). This is available only as an action in the PO project - we don't want it elsewhere

I had been creating a manual rule per code base project, which is limited to run in the PO's project, to create and link a Story ticket with some default text in the appropriate fields, assigned to them. 

As we're starting to write stories for more code bases, the list or automations is growing, so I'd like to find a way to create a single rule that allowed the PO to input the project where they would like the Story created, but...

If I use the userinput smart variable from the prompt in the manual trigger step, the Create action can't find the Story issuetype. If I use a known project to set the issuetype, then put the smart variable into the Project field on the Create step, the rule won't save.

Is there a way to achieve the outcome we need - from the PO Task, a new linked Story in a code base project based on user input when running the rule?

Maybe a trick of cloning the Task, editing to clear the fields, link the tickets, move the clone to the desired project and change the issue type... but how to move projects in a rule without making the rule multi-project and thus available in other projects?

download.pngdownload.png

2 answers

1 accepted

0 votes
Answer accepted
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.
April 10, 2024

Hi @Dave Furlani 

I recall a similar question from two weeks ago about dynamically selecting the project from a manual trigger's user inputs, and that did not work.  What was tried was:

  • using user inputs in the project field,
  • not selecting the project and using a JSON edit to set the project, and
  • selecting the current project in the dropdown and then changing the project with JSON.

The workarounds were:

  1. for a small, known number of projects, use a if / else block of conditions
  2. for an unknown number of projects, add the issue with the REST API function and the Send Web Request action

There are open suggestions to add "Move Issue" to both the REST API and to automation actions, such as these:

https://jira.atlassian.com/browse/AUTO-549
https://jira.atlassian.com/browse/JRACLOUD-61359
https://jira.atlassian.com/browse/JRACLOUD-70305

Kind regards,
Bill

Kalyan Sattaluri
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.
April 10, 2024

To add to Bill's answer, other than If/Else (and web request), one other option is to create a lookupTable as mentioned by @Trudy Claspill in below link. Please review the below thread's solution as the other poster had similar requirement. 

https://community.atlassian.com/t5/Jira-Software-questions/Re-Manual-Automation-to-clone-into-other-projects/qaq-p/2663232/comment-id/1006889#M1006889

If this solves your ask please consider accepting solution as it benefits folks in the future. Thanks!

Dave Furlani
Contributor
April 10, 2024

Thanks @Kalyan Sattaluri, While the lookup table is a nice option for a limited/known list of projects, we have many and they'll grow this year, so ideally I have a one-size-fits-all solution.

@Bill Sheboy - you got me thinking about the web request. I'm now thinking the logic could be:

  1. Ask user for input
  2. Use a web request to get the project ID for their project
    • https://<domain>/rest/api/latest/project/{{userInputs.targetProj.toUpper()}}
  3. Use the project's ID returned from that in the clone action to clone the PO ticket to the desired location (because the clone action seems to be ok with a ProjectID, but not ProjectCode
    • In the clone step, remove/replace unwanted text in fields and set the default text for new stories, as well as link to the trigger

The issue I'm having here is getting the response from the web request, to which end I assume I'm doing something wrong in the config that action, because the URL works fine in a browser, and I'm getting a 200 response, but the payload in the response seems to be empty. Can you see where I'm going wrong with the below?

download.png

8e9cbd40-5ef6-43ff-a783-7b4e6565673f.png

 

Kalyan Sattaluri
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.
April 10, 2024

Hello @Dave Furlani 

Can you just hardcode:  rest/api/3/project/DFXXSYS

In the same screen, expand "Validate your web request configuration", click Validate and after 200, expand payload and check if you are seeing response body in payload?

image.png

Kalyan Sattaluri
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.
April 10, 2024

BTW, just FYI.  your project ID will be accessible at {{webResponse.body.id}} , of course after you are able to see the response that is..lol

Like Dave Furlani likes this
Dave Furlani
Contributor
April 10, 2024

I get a 404 error, although the same URL works in the browser for me. See below

Funnily enough with the smart variable in the Web request URL, and no optional headers provided, the validation gives me a 200 response, making think it was going to work.

I notice you have Authorization = Basic in your config, although that makes no difference to the outcome for me when I set it, with or without also adding Content-Type = Application/JSON. Do you have any other optional headers in your step's config?

download.png

rest.png

Dave Furlani
Contributor
April 10, 2024

And I've worked out it was giving me a 200 error because the user input wasn't getting added to the end of the URL, because I has .toUpper() instead of .toUpperCase()

Now that I've fixed the web request so it is requesting a specific project as required, I'm getting a 404 error in the audit logs

 

Error response HTTP body: {"errorMessages":["No project could be found with key 'DFXXSYS'."],"errors":{}}
Error publishing web request. Response HTTP status: 404
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.
April 11, 2024

Hi, Dave!

I believe that error can be returned when the rule actor does not have browse permissions for the project.  Have you checked that?

Kalyan Sattaluri
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.
April 11, 2024

Hello @Dave Furlani 

Based on what you have shared (that you were able to see the response in the browser) but REST call not giving you the response, issue is with the credentials you passing.

Are you base64 encoding your token as listed here - LINK.

You cannot directly use the API token from Jira, you have to follow the steps listed above:

I will briefly list the steps:

  • Create token from here
  • Then using your emailID, form a string => emailID:token
  • Then if you are on windows, open powershell, paste below replacing bolded parts, hit enter

$Text = ‘emailID:token
$Bytes = [System.Text.Encoding]::UTF8.GetBytes($Text)
$EncodedText = [Convert]::ToBase64String($Bytes)
$EncodedText

What you get as output from above is base64 encoded string which you need to use with Basic auth.

So in your header, you give Authorization: Basic <base64string>

Back in your automation rule, pass this value, Click Validate to confirm 200 response.

Hope it helps.

Like Bill Sheboy likes this
Dave Furlani
Contributor
April 11, 2024

That seems to have done the trick. Thanks. While the doco suggests the API does not need authentication, that seems to only be for the request without a project key. As @Bill Sheboy suggests, if there's a project key in the request, the API needs to be authenticated. That's why I was getting a 200 when the request had no key, and a 400 when it did.

Adding a key seems to have fixed this. Thanks @Bill Sheboy and @Kalyan Sattaluri 

Like # people like this
Dave Furlani
Contributor
April 11, 2024

Talking to Atlassian and the A4J user's email address can't be used. Each site must create a service account user (licensed) if they don't want to tie Auth keys to a human user

Like Kalyan Sattaluri likes this
Dave Furlani
Contributor
April 11, 2024

For anyone wanting to create a similar rule, here's the logic

Create a linked story A4J rule.png

0 votes
Ste Wright
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 9, 2024

Hi @Dave Furlani 

Can I just confirm the need?

Is it that you only want the "manual trigger" to be activated from one Project, but create issues in multiple Projects as an outcome?

Ste

Dave Furlani
Contributor
April 9, 2024

Ideally, yes

The existing rules I have are single project rules that only appear in the PO project, but create tickets in the system layer projects. I'm hoping to replace the growing list of those rules with a single rule 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events