Automation rule is not updating custom field
Asked by Srujana Deva:

I'm trying to edit the issue field when there is an issue transition.

![rule.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/121649i690771B60CFBFA79/image-size/large?v=v2&px=999 "rule.PNG")

I have set the edit issue field condition with smart value -\> {{issue.created.diff(issue.resolved).hours}}  

With this I'm trying to find the get the data in hours and mapped it to a custom number field.

![edit issue field.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/121650i19C863BE012FD619/image-size/large?v=v2&px=999 "edit issue field.PNG")

Rule is executed but data is not updated in the custom field.  

Please help me


Answers:
author: Sherry Goyal
body: Hi [@Srujana Deva](/t5/user/viewprofilepage/user-id/4190205)

{{issue.created.diff(issue.resolved).hours}} will give negative value as order matters!

Try other way around: {{issue.resolved.diff(issue.created).hours}} or else please add try to paste the value to audit log and test the output. You can take help from [here](https://support.atlassian.com/jira-software-cloud/docs/debug-a-rule/) to debug a rule.

Thanks  
Sherry

comments: author: Srujana Deva
body: I changed the smart value too and even then no value is updated in the custom field. Let me add debug after updating {{issue.resolved.diff(issue.created).hours}}.

The audit log says it is successful.

![audit log.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/121799iF6BA22BBC512470E/image-size/large?v=v2&px=999 "audit log.PNG")


author: Sherry Goyal
body: Technically resolution means when it moves to done status. I think you are moving it to another status. You should try {{now.diff(issue.created).hours}}

I would suggest to add "Log action" and try to print values there if this does not works.


author: Srujana Deva
body: I tried adding debug for your last smart value {{issue.resolved.diff(issue.created).hours}}. Nothing in logs too.  

Let me try what you suggested right now and add debug. I am adding log to print values but earlier didn't see anything.


author: Srujana Deva
body: Thanks [@Sherry Goyal](/t5/user/viewprofilepage/user-id/3873899)   

{{now.diff(issue.created).hours}} resolved the issue. I am able to seed the data to custom field now.


author: Liam Green
body: Hi [@Srujana Deva](/t5/user/viewprofilepage/user-id/4190205)

Welcome to the Community!

Have you checked that the name of the field is correct? It isn't always easy to spot.

Regards, Liam

comments: author: Srujana Deva
body: Hi [@Liam Green](/t5/user/viewprofilepage/user-id/3084048) ,

Thank you for the reply!  
Yes I have provided the name of the field right.  

I see that the rule is executed but data is not updated in the custom field.  

I took the formula from <https://community.atlassian.com/t5/Automation-questions/How-to-calculate-the-resolution-time-as-a-difference-between-2/qaq-p/1488447>

Am I doing it right?

Regards,  
Srujana


author: Srujana Deva
body: What I want to do is simple when the issue is transitioned to "In QA" status then I want to update "Time taken to resolve" custom field with "{{issue.created.diff(issue.resolved).hours}}" which gives me the duration between created and resolved in hours.


author: Liam Green
body: Can you take a screenshot of the audit log from Automation please?


author: Srujana Deva
body: ![audit log.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/121798i8487C64D6511E9D3/image-size/large?v=v2&px=999 "audit log.PNG")  
Rule execution is working fine. I'm seeing success status but no value updated in the custom field


author: Jay Keck
body: I'm having the same problem, where I'm performing a math operation on a number field using smart values and it doesn't seem to do anything. My log messages show the number being the same before and after the increment operation, no errors in audit log, but my number isn't changing. I'm wondering if anyone has solved this, are smart values not supported within an automation script assign operation?


Tags: smart-value