Forums

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

Error when settting current date on a field when status changes to In Progress

Jim Smith
Contributor
August 1, 2023

This is using Jira Automation.  The date field I need populated is in Jira Product Discovery (Team managed project) and the update should occur when I transit the workitem to "In Progress" in Jira Software.

I have the following JSON:

{
"action": "edit_issue",
"fields": {
"PI Start": "{{now.mediumDate}}"
}
}

That when testing throws an error,

"Error editing issues

<issuekey> (We couldn't save your changes. Copy your content, then try reloading the page.)"
What am I missing?

3 answers

1 accepted

0 votes
Answer accepted
Jim Smith
Contributor
August 3, 2023

The solution came from Jistin Sitarz from JPD Support:

Essentially, these date fields within JPD are actually a date range field, and the range is expressed with a start and end value, in the format of:

{"start":"2022-12-01","end":"2022-12-31"}

This is a little different than dates elsewhere in Jira, and because of this, if we want to copy a date from another Jira issue or use a Jira function to pull the current date, we need to format it to match what JPD is expecting. We can do that like this - by inserting the smart value for the current time within the data structure (and also escaping the internal double quote characters):

"{\"start\":\"{{now.jqlDate}}\",\"end\":\"{{now.jqlDate}}\"}"

And, in the end, we get the following that we can add to the Advanced Fields section of our automation rule:

{
    "fields": {
        "customfield_11171": "{\"start\":\"{{now.jqlDate}}\",\"end\":\"{{now.jqlDate}}\"}"
    }
}  
Kai Becker
Community Champion
August 3, 2023

Hi @Jim Smith 

That's why I wanted the JSON, to see what format it is. 

Glad that it has been resolved in the end!

0 votes
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.
August 1, 2023

Hi @Jim Smith 

For a question like this, please post images of your complete automation rule and the audit log details showing the rule execution.  Those will provide context for the symptom you are seeing.  Thanks!

Until we see those...

You describe trying to use JSON to edit the field.  Have you tried to select the field from the drop-down list in the rule action to edit the issue?

And...when using the advanced edit with JSON, I recommend reviewing this information to confirm you have the correct syntax for that rule action: https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/

And...this how-to article when you need to determine if a field is supported by rules, and what the exact smart value is: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

Kind regards,
Bill

Jim Smith
Contributor
August 2, 2023

Good morning Bill, thank you for your help! Here is the JSON for the automation rule:

{"cloud":true,"rules":[{"id":13700897,"clientKey":"d88b9191-773c-3001-ac86-ac5e2a5ecd89","name":"Update PI Start to NOW","state":"ENABLED","description":"","authorAccountId":"712020:977bff7a-a0c5-4ee1-ac25-7c01a7a56f5b","actor":{"type":"ACCOUNT_ID","value":"557058:f58131cb-b67d-43c7-b30d-6b58d40bd077"},"created":1690551082369,"updated":1690976583837,"trigger":{"id":"298102707","component":"TRIGGER","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.issue.event.trigger:transitioned","value":{"eventKey":"jira:issue_updated","issueEvent":"issue_generic","fromStatus":[],"toStatus":[{"type":"NAME","value":"In Progress"}]},"children":[],"conditions":[],"connectionId":null},"components":[{"id":"298102708","component":"BRANCH","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.issue.related","value":{"relatedType":"linked","jql":"","linkTypes":["implements"],"onlyUpdatedIssues":false,"similarityLimit":40,"compareValue":0},"children":[{"id":"298102709","component":"ACTION","parentId":"298102708","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[],"advancedFields":"{\n\t\"fields\": {\n\t\t\"PI Start\": \"{{now}}\"\n\t}\n}\n ","sendNotifications":true},"children":[],"conditions":[],"connectionId":null}],"conditions":[],"connectionId":null}],"canOtherRuleTrigger":false,"notifyOnError":"FIRSTERROR","projects":[],"labels":[],"tags":[{"id":38378813,"tagType":"IS_RULE_UPDATED","tagValue":"true"}],"ruleScope":{"resources":["ari:cloud:jira::site/78db38a2-52b2-44cf-ac8f-1689cf94905f"]},"ruleHome":{"ruleLifeCycleHome":{"locationARI":"ari:cloud:jira-software::site/78db38a2-52b2-44cf-ac8f-1689cf94905f"},"ruleBillingHome":{"locationARI":"ari:cloud:jira-software::site/78db38a2-52b2-44cf-ac8f-1689cf94905f"}},"writeAccessType":"UNRESTRICTED","collaborators":[],"billingType":"NORMAL"}]}

 

With the screen shot of the audit log:

Screenshot 2023-08-02 at 6.51.05 AM.png

I've tried multiple configuration changes in the JSON and nothing seems to work.  The "PI Start" field is "customfield_11171" and I've tried using that in the JSON and it fails with the same error message.

I tried to find the smart value for the field and was unsuccessful, I can send you the output from the rest API, however that is quite lengthy! Let me know and I'll include it as well if needed. 

My gut feel here is that there may be an access issue between two products: JPD and Jira Software.  I'm updating a field in Jira Software and asking a field in a JPD Team Managed project to be set.  Is the fact that it is a team managed project an issue?

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.
August 2, 2023

If you tried the "find your smart value" how-to and did not see your field, then it is not supported by automation rules (because it is not supported by the REST API for issues).

However...I just tried that how-to technique for our JPD project and found all of the fields we added, including the dates.

Looking at the JSON edit guidance, it shows using the jqlDate format (yyyy-mm-dd) so perhaps try that for your field edit:

{
"fields": {
"customfield_11171": "{{now.jqlDate}}"
}
}

And if that does not work, please post an image of the edit action from your rule so we can see this in context.

Jim Smith
Contributor
August 2, 2023

Hello Bill, as a clarification...when I performed the query for the Smart Value, the field "PI Start" is shown in the resulting JSON, however I'm not able to get the smart value name as described in the how-to article.  I'll try the suggested modification and send the resulting image.

Like Bill Sheboy likes this
0 votes
Kai Becker
Community Champion
August 1, 2023

Hi @Jim Smith 

welcome to the community and thanks for your question.

I'm not a hundred percent sure about the Project Discovery fields, but I don't think it is necessary to put mediumDate after now. 
You should be good to go with now. Jira should sort this out internally. 

Jim Smith
Contributor
August 1, 2023

Hi Kai, I actually had {{now}} all by itself as you suggested, however it still threw the same error.  I changed it to {{now.mediumDate}} as I thought it might be a date format incompatibility when the automation was updating the date field in JPD.

Kai Becker
Community Champion
August 1, 2023

Hi @Jim Smith

thanks for clarification. I'm not a hundred percent sure about the field update, as I don't have a PI Start field in my product discovery project.

What I would recommend: open an issue from the project (that has the field set) via rest api:

https://<your site name>.atlassian.net/rest/api/3/issue/<example key>

and look for your specific field. Copy field and value format and paste it here, so we can have a look.

Kai Becker
Community Champion
August 2, 2023

Hi @Jim Smith 

could you please post the json of an issue that has value in the PI field, as I requested? 

One more question: Do you update the field via advanced edit?

Jim Smith
Contributor
August 2, 2023

Thank you Kai, this has been resolved.

Suggest an answer

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

Atlassian Community Events