Use Jira Automation to dynamically set Tempo Time Account field with JSON

Andy Creech
Contributor
April 5, 2021

Hi All,

I am trying to set the Tempo Time add-in's custom field of account using the Jira Automation option to write a JSON. Ideally I want to set the value of the Account using the value of the custom Jira Management Organization field. 

Here is where I am getting hung up, I cannot set the Account field from tempo time at all. I am getting the following error in the logs. 

(Can not deserialize instance of java.lang.Long out of START_OBJECT token at [Source: N/A; line: -1, column: -1] (io.tempo.jira__account))

My json is formatted as follows

{
"update": {
"customfield_10075": [
{
"set": {"id": 2}
}
]
}
}

I have tried calling the field by name and I have tried setting the fields options using their values. 

 

When calling the rest api for the allowable fields, I find my field in the list with the following results

 

  • customfield_10075: {
    • required: false,
    • schema: {
      • type: "option2",
      • custom: "com.atlassian.plugins.atlassian-connect-plugin:io.tempo.jira__account",
      • customId: 10075
      },
    • name: "Account",
    • key: "io.tempo.jira__account",
    • operations: [
      • "set"
      ],
    • allowedValues: [
      • {
        • id: 2,
        • value: "Client1"
        },
      • {
        • id: 5,
        • value: "Client2"
        }
      ]
    },

 

Your help would be greatly appreciated. 

2 answers

3 votes
Ed Letifov _TechTime - New Zealand_
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 4, 2022

Hello,  @Andy Creech 

Here is a solution on how to set the Account based on Tempo Account's KEY matching JSM Organisation's name, when taken without spaces and in upper case i.e. JSM Organisation name "Test Organization" -> Tempo Account "TESTORGANIZATION"

  • on create (or any other event, depending on what you are already doing)
  • add "send a web request" action, GET, web request body is empty, delay execution until response is received, to:
    https://api.tempo.io/core/3/accounts/{{issue.customfield_11500.name.remove(" ").toUpperCase().urlEncode}} 
    you will have to specify "Authorization" token as
    Bearer xxxx
    for xxx value go to your Jira Cloud/Apps/Tempo/Settings/API integration and create a token
  • add "edit the issue" action, don't select any fields, instead open up More options, uncheck email sending, specify this in JSON 
    {
        "fields": {
            "Account": {{webhookResponse.body.id}}
        }
    } 

     

The resources to read through are these:

https://tempo-io.atlassian.net/wiki/spaces/KB/pages/2249589149/Handling+time+buckets

https://apidocs.tempo.io/ (you need /accounts/{key} one)

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/

https://support.atlassian.com/cloud-automation/docs/debug-an-automation-rule/

1 vote
Andy Creech
Contributor
April 6, 2021
Andy Creech
Contributor
April 13, 2021

So for anyone tracking this, I resolved the initial error message. However you can only set Tempo Time account using the unique key, you cannot use the name of the Account. Therefore there is not a direct way to assign Account based on Jira Service Management custom field Organization. 

In theory a smart person could create a way to use the Org field as an input to look up in a list through smart values the name of the account and return the unique key. However that is beyond my abilities. 

Like Nigel Budd likes this

Suggest an answer

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

Atlassian Community Events