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

Using a smart value to add an organisation to a ticket

Oliver Scott-Hughes (CX) September 17, 2020

I have a value stored in a smart value lets say "ABC Company".

 

Using Project Automation, I want to set a ticket's organisation to this value (I will ensure there is an organisation called "ABC Company").

 

It doesn't appear to be supported the simple way so I'm keen to hear some more advanced solutions.

 

Cheers

Oliver

 

edit org.PNG

 

2 answers

1 accepted

4 votes
Answer accepted
Oliver Scott-Hughes (CX) November 9, 2020

Managed to get this working with the help of Atlassian support.

For posterity, the method:

 

Use the "send web request" in automation, post custom webhook data:

{
"name": "{{smartvaluecontainingmyorgname}}"
}

 

Then Edit issue, advanced:

{
"fields": {
"Organizations": [{{webhookResponse.body.id}}]
}
}

Alex
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.
May 11, 2021

Hi @Oliver Scott-Hughes (CX) 

This solution is pretty neat and will solve my case as well.

Could you share an example of the Webhook URL to send web request ? I did not manage to identify what is the API that provides the organization data.

Thanks,

Alex

Oliver Scott-Hughes (CX) May 11, 2021

Hi Alex

 

I'm glad you found this helpful - it took me a lot of effort to get this working!

 

The fields I am using are as follows:

Webhook URL: "https://[myjiradomain].atlassian.net/rest/servicedeskapi/organization"

Headers box 1: "Authorization"

Headers box 2: "Basic [myapitoken]"

HTTP Method: "POST"

Webhook body: "Custom data"

 

I hope this helps.

 

Cheers

Oliver

Alex
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.
May 12, 2021

Thanks, @Oliver Scott-Hughes (CX), it worked perfectly!

A simple addition based on my use case. Since I am using JSM Data Center, this API is still experimental, thus another header was required.

 

Headers box 3: "X-ExperimentalApi"

Headers box 4: "opt-in"

Hamzah Mohamed May 9, 2022

Amazing solution @Oliver Scott-Hughes (CX) It shouldn't be this hard but since the organisations field doesn't seem to work like any other fields it's no suprise this is required.

 

One thing I need to add after almost a year of changes: the name "webhookResponse" is "webResponse". Also, remember to check the box that says to wait until a response is received to move to next steps. Otherwise you will just have an empty body.

Like Artem Chatlikov likes this
2 votes
Dirk Ronsmans
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 18, 2020

Hi @Oliver Scott-Hughes (CX)  and welcome to the community,

I've take a look and tried some thing and here's what I came up with:

Instead of setting the field through the UI you can go to the Advanced portion of the Edit Issue and create a JSON Payload.

To set the organization that would be:

{
"fields": {
"Organizations": [4]

}
}

 

This will add organization with id "4" to the issue.

The id you can get from the url when you open an organization:

for example with me: ]/jira/servicedesk/projects/ISD/organization/4

So for one I think you would need to store the Id of the organization that you want and not the name.

Then you can use the smart value system to get the value fro mthe custom field:

{{issue.YOURCUSTOMFIELDNAME}} (and replace that in the JSON)

There might be a cleaner method of "adding" cause there should be an operation you can give:

 "name": "Organizations",
"key": "customfield_10002",
"autoCompleteUrl": "/rest/servicedesk/1/organisations/project/10003/search?query=",
"hasDefaultValue": false,
"operations": [
"add",
"set",
"remove"
]

 

but the idea is that using that advanced portion you basically send a payload like you would in a REST call  (cause thats probably what it is) but to a predefined endpoint to edit the issue.

Oliver Scott-Hughes (CX) September 20, 2020

Hi Dirk

 

Thanks for the response. This may work if there is a way to convert an org's id from it's name? I only have the name available in my smart value (I'm parsing it from text).

Cheers

Oliver

Dirk Ronsmans
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 20, 2020

Hi @Oliver Scott-Hughes (CX) ,

I'm afraid not, your smart value is essentially just text so it has not attributed to pull from. As far as i can see there is also no way to parse the textual value to a id in Automation. (using a script you'd probably could just do a GET of the organizations and see their ID's)

The only way my 8am brain can come up right now is to use a hardcoded conversion and that works depending on the amount of organizations you have and how often then change.

I tried it also in the other formatting but without any luck on text. the add operation just expects a number parameter.

{
"update": {
"Organizations": [{
"add": 4
}]
}
}

Imo, you could either:

1) Create a 2nd automation that is basically a collection of IF statements that updates a helper field (e.g. OrgID) that at creation converts the textual organization to the id.

And then use that OrgID field change in your initial automation to set hte correct ID from that smartvalue.

OR

2) Add these if's in your original automation and hardcode the id in to your json update.

 

neither seems to be a great solution and depending on the amount of organizations i would go 1) (if you have a lot of them so you can do the ID maintenance in one place) or 2) just to have a single automation.

 

Sadly the only way this will be different is when you can pass a textual representation of the organization to the call (or run a small script in your automation). I understand Atlassian's point of view here so that when you change the organization name the ID remains the same.

If you don't find either solution works for you I can only suggest to open either:

Move to something like Scriptrunner so you can do the GET first and then a PUT to set it and have more control.

OR/AND

Open a call with Atlassian (as they own the Automation part now) to see whether they add some component that allows you to add small scripts..

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events