Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,328,569
Community Members
 
Community Events
168
Community Groups

How to include custom field values in Webhook custom payload

Hi there

We have a requirement to pass custom field values to an external application and our plan is to use the Webhook automation rule to support this.

I can't seem to get smart values to post as part of the JSON payload.

Any help appreciated.

Thanks

Andrea

Screenshot 2020-10-07 at 13.03.23.png.

1 answer

1 accepted

0 votes
Answer accepted
Andy Heinzer Atlassian Team Oct 08, 2020

Hi Andrea,

I see that you are trying to setup an automation rule in order to send a json payload, but this is not working as expected.  From looking at your screenshot of the configuration, it looks like you're trying to setup a rule that will create a new request in a Jira Service Desk project.

Your json payload looks to be close, but you need to encapsulate the smart value in double quotes.  You can see an example of the payload needed in the REST API example of POST /rest/servicedeskapi/request.

Try changing that one line to

"summary": "{{issue.customfield_10131}}"

In turn that should pass the value of that field on this issue into summary field, so long as that custom field is just a text field with some value.  If this is a different kind of custom field, such as a select list, or cascade select list, you might find that the output looks a bit different here.  And if this field has no value, you might find that the json payload is empty for that particular webhook.

I always like to use a service like https://postb.in/ when testing out my webhooks to make sure that the payload I expect I am sending is actually being received by the endpoint.  It makes for a useful means to test out webhooks.

Andy

Thanks for your response Andy.

I'm still getting blank values when using the custom field smart value within the JSON.

As a workaround, I've added an action before the Send Web Request action, to post the custom field value as a comment.

I'm then using the "{{issue.comments.last.body}}" within the JSON, and this passes.

It does seem weird that the JSON isn't picking up the value from the custom field however.Screenshot 2020-10-09 at 10.50.19.png

Andy Heinzer Atlassian Team Oct 09, 2020

I am not expecting that you would need to use the .value postfix like you have in your most recent screenshot here.  That does not show the value the field has, but rather .value is documented in Smart values - general as showing a property value.  Such property values are null by default, but could be used by apps/addons in Jira in order to store some kind of meta-data about the field/issue/project/etc.

I would try change your description from

"{{issue.customfield_10081.value}}"

to just

"{{issue.customfield_10081}}"

in order to show the current value that custom field has.

 

If that does not work as expected, instead of trying to identify the field by the unique 5 digit identifier, perhaps you could just use the name of the field for the smart value, such as

"{{issue.MyCustomFieldName}}"

 

And if that doesn't work as expected here, then I have a few questions for you to try to learn more here:

  1. What type of field is this custom field in question? (Single line Text, multi-line text, select list, number, label, etc)
  2. Is this a next-gen project?

Try the first two alternatives above, and if that doesn't work, please let me know more.

Andy

Hi Andy

Neither of the suggestions appear to offer a solution unfortunately.

The two fields I have created for each scenario are text fields, so from everything I've read, they should be able to be used.

Project type is Classic.

Thanks

Andrea

Thanks for the suggestions, it worked for me. I am able to get the custom fields data

Have now been able to successfully post using smart value {{issue.MyCustomFieldName}} to various endpoints.

Hi Andrea, I am running into the same issue as you were, but can not seem to figure it out. Is it possible to include a screenshot of how you got it to work?

Hi @Dawn Varughese we did get this working in the end, following the accepted answer above.

We tend to use {{issue.Custom Field Name}} rather than the custom field id, but both should have the same result.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
Community showcase
Published in Jira Service Management

Just dropped! New Lightning Talks: Marketplace episodes

  Hi everyone! Want to learn how customizing your Atlassian apps can improve workflows, enhance teamwork, and boost efficiency across your organization? Check out our new, 15-minute Lig...

106 views 0 0
Read article

Atlassian Community Events