A4J - Limiting the visibility of a multi-project rule with a manual trigger to one project
Asked by Dave Furlani:

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.png](https://community.atlassian.com/t5/image/serverpage/image-id/317342i636094FA004DEDBF/image-size/large?v=v2&px=999 "download.png")![download.png](https://community.atlassian.com/t5/image/serverpage/image-id/317343iE338A50D29488924/image-size/large?v=v2&px=999 "download.png")


Answers:
author: Bill Sheboy
body: Hi [@Dave Furlani](/t5/user/viewprofilepage/user-id/5112923)

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

comments: author: Kalyan Sattaluri
body: 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](/t5/user/viewprofilepage/user-id/3569011) 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!


author: Dave Furlani
body: Thanks [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306), 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](/t5/user/viewprofilepage/user-id/1685313) - 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](https://community.atlassian.com/t5/image/serverpage/image-id/317594iE4E23023172E4132/image-size/large?v=v2&px=999 "download.png")

![8e9cbd40-5ef6-43ff-a783-7b4e6565673f.png](https://community.atlassian.com/t5/image/serverpage/image-id/317574i95498874A8127BB3/image-size/large?v=v2&px=999 "8e9cbd40-5ef6-43ff-a783-7b4e6565673f.png")


author: Kalyan Sattaluri
body: Hello [@Dave Furlani](/t5/user/viewprofilepage/user-id/5112923)

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](https://community.atlassian.com/t5/image/serverpage/image-id/317581i95C60524147FC61C/image-size/large?v=v2&px=999 "image.png")


author: Kalyan Sattaluri
body: 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


author: Dave Furlani
body: 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](https://community.atlassian.com/t5/image/serverpage/image-id/317588i3670C466B123A51C/image-size/large?v=v2&px=999 "download.png")

![rest.png](https://community.atlassian.com/t5/image/serverpage/image-id/317593iA6C898198996BA7C/image-size/large?v=v2&px=999 "rest.png")


author: Dave Furlani
body: 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


author: Bill Sheboy
body: 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?


author: Kalyan Sattaluri
body: Hello [@Dave Furlani](/t5/user/viewprofilepage/user-id/5112923)

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](https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/#supply-basic-auth-headers).

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](https://id.atlassian.com/manage-profile/security/api-tokens)
* 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.


author: Dave Furlani
body: 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](/t5/user/viewprofilepage/user-id/1685313) 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](/t5/user/viewprofilepage/user-id/1685313) and [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)


author: Dave Furlani
body: 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


author: Dave Furlani
body: For anyone wanting to create a similar rule, here's the logic

![Create a linked story A4J rule.png](https://community.atlassian.com/t5/image/serverpage/image-id/317862iBF201D6372F01475/image-size/large?v=v2&px=999 "Create a linked story A4J rule.png")


author: Ste Wright
body: Hi [@Dave Furlani](/t5/user/viewprofilepage/user-id/5112923)

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

comments: author: Dave Furlani
body: 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


Tags: jira-cloud