Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Creating issues and setting up custom fields with webhooks and Jira automation

N Y
Contributor
October 26, 2022

Hi,

first a little bit of context:
I'm automating a process using JIRA as kind of a workflow-management system.
The scenario is as follows:
A user fills out a form, which is displayed on the companies website.
On submission, a HTTP POST to a Jira webhook adress is sent.
This triggers an automation rule that creates a new issue, starting a
HR process based on the information provided by the form.

My mission is to map the JSON form-data to custom fields upon issue creation,
so that the relevant process participant can act according to the data supplied.

As stated by the documentation here its possible to access the JSON payload via {{webhookData}}
and set  custom fields upon issue creation based on their supported types and operations.

When I tried this to set a custom field with properties {"type": "string"} and "operations[0]: set"

{
"fields": {
"customfield_10060": {"set": "{{webhookData.someData}}"}

   }
}

or

{
"fields": {
"customfield_10060": {"value": "{{webhookData.someData}}"}

   }
}

the automation rule didnt run with the error message:
jira operation value must be a string.

Then I tried  "customfield_10060": {"value": "someString"}
and "customfield_10060": {"set": "someString"}


which also led to the same error.


But when I did this, based on a stackoverflow post 

{
"fields": {
"customfield_10060": "{{webhookData.someString}}"
}
}
the rule executed properly, creating the issue and setting the custom field with the incoming JSON data.

Why is this, whats the mechanism behind it?
Where can I find documentation about this kind of behavior?
I wanna know how to set custom fields of type array or date,
without guessing the solution.

1 answer

1 accepted

2 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.
October 27, 2022

Hi @N Y -- Welcome to the Atlassian Community!

The method used in the JSON expression to set the custom field value depends upon the custom field's type. 

In my experience when the custom field value doesn't set, it is either because the wrong location is being source from the webhook data (or API response), or because the incorrect custom field type is assumed for the JSON expression.  I recommend writing the source data to the audit log when you are unsure what Jira is trying to parse.

 

Please refer again to that documentation you noted as it shows examples of the various types: https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/

There are also some JSON functions to help when parsing the webhook data, as described here: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-json-functions/

For cascading and Insight fields, there is additional documentation linked to those same pages.

Kind regards,
Bill

N Y
Contributor
October 27, 2022

Hi Bill,
thank you!
The JSON functions are really helpful,
and you're absolutely right, the documentation page provides examples to my question at the end.

I obviously overlooked the part, probably because I was searching for a more general answer.

Like Bill Sheboy likes this

Suggest an answer

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

Atlassian Community Events