Fieldtype "Last Public Comment" in calculation returns null to a "Number Field"
Asked by dahu:

Hello,

I got a Field of the type "Last Public Comment Date" with the Name "VorgangDatumLetzer?ffentlicherKommentar" where the timestamp from the last comment (not last public comment?!?!) is saved.

Then I want to calculate how long ago (in days) the last comment was set.

I use this:

{{now.diff(VorgangDatumLetzer?ffentlicherKommentar).days.abs}}

That worked fine with a field from type "Date Time Picker", where I saved the timestamp of the last comment with a rule when a comment was set.

But we have to save rule executions now and because of that I want to use the "Last Public Comment" - Fieldtype to calculate the age of the last comment.

The result of the calculation then is set as value of a field of type "Number Field" called "VorgangLetzterKommentarAlter". In the .json view the value of this field always is "null".

Has somebody an idea how to handle this?

Best Regards,

Daniel

![NumberField.png](/t5/image/serverpage/image-id/306597i4A7000CFA8E2BF16/image-size/large?v=v2&px=999 "NumberField.png")![fieldtype_lastPublicCommentDate.png](/t5/image/serverpage/image-id/306596iF40412163E9D8508/image-size/large?v=v2&px=999 "fieldtype_lastPublicCommentDate.png")![json-field-value.png](/t5/image/serverpage/image-id/306595i98B4DC76B762B0E8/image-size/large?v=v2&px=999 "json-field-value.png")![json-field.png](/t5/image/serverpage/image-id/306598iEC33BE7B109D6E72/image-size/large?v=v2&px=999 "json-field.png")![json_number_field_value.png](/t5/image/serverpage/image-id/306599iFB9D7B59B6326FC4/image-size/large?v=v2&px=999 "json_number_field_value.png")![json_number_field.png](/t5/image/serverpage/image-id/306600iF6102E2F2947922F/image-size/large?v=v2&px=999 "json_number_field.png")


Answers:
author: dahu
body: Hi [@Kai Becker](/t5/user/viewprofilepage/user-id/1178079) ,

the Problem was not solved.

I did what I needed with SLA.

Thank you for your help!

Best Regards,

Daniel


author: Kai Becker
body: Hi [@dahu](/t5/user/viewprofilepage/user-id/5366058)

on your second screenshot the custom field has the value 0.0.

How did it get this value? Does it work sometimes?

Does the Automation rule report errors in the audit log?

comments: author: dahu
body: Hello Kai,

thank you for your answer.

Because of value 0.0. I can not tell from where or when the 0.0 value came from.

Always when I do it again, I got "null".

No, there is no error in the audit log of the rule.

Best Regards,

Daniel


author: Kai Becker
body: Could you try to add a log action to your rule and log the value of your smart value:

```
{{now.diff(VorgangDatumLetzer?ffentlicherKommentar).days.abs}}
```


author: dahu
body: Hello [@Kai Becker](/t5/user/viewprofilepage/user-id/1178079) ,

thank you for your advice with the log action.

For

```
{{now.diff(VorgangDatumLetzer?ffentlicherKommentar).days.abs}}?
```

I dont get a result in log action or if I set the result as value of a field the value is still "null"

But I had a look at the time-formats of {{now}} and {{VorgangDatumLetzer?ffentlicherKommentar}} and they are different:  

{{now}}: 2024-02-20T07:31:33.7+0000  
{{VorgangDatumLetzer?ffentlicherKommentar}}: 2024-02-15 14:31:27.648  

Maybe that is the problem?  

But I am not able to get the same time-format for them.

When I want to change the format like {{VorgangDatumLetzer?ffentlicherKommentar.jqlDateTime}} I get no result.  

I can change the time-format of {{now}} like e.g. {{now.jqlDateTime}} but there is no time-format given at [smart values date and time](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/) in the first table that matches with the time-format of {{VorgangDatumLetzer?ffentlicherKommentar}}.  

Do you think that this could be the problem and if yes do you have an idea how to bring them to the same format?  

Thank you very much!

Best Regards,

Daniel


author: Kai Becker
body: Hi [@dahu](/t5/user/viewprofilepage/user-id/5366058)

I would use .jiraDate for both, now and the field value. As you are calculating days between these two dates there is no need to mess around with time data.

Could you give this a try?

Should probably look like this:

```
{{now.jiraDate.diff(VorgangDatumLetzer?ffentlicherKommentar.jiraDate).days.abs}}?
```


author: dahu
body: Hi [@Kai Becker](/t5/user/viewprofilepage/user-id/1178079) ,

unfortunately it does not work.

VorgangDatumLetzer?ffentlicherKommentar is not able to be converted into an other format, even not .jiraDate.

With a log action it brings no result and

```
{{now.jiraDate.diff(VorgangDatumLetzer?ffentlicherKommentar.jiraDate).days.abs}}?
```

brings no result too, or as value for a field it is "null"


author: dahu
body: Hi [@Kai Becker](/t5/user/viewprofilepage/user-id/1178079) ,

I had contact with Atlassian-Support-Chat an they opened a ticket for that: [PCS-256640](https://support.atlassian.com/requests/PCS-256640)

I wanted to share the ticket with you, but I think I do not have enough information about you to fill the share field.

So if you are interested, give me information for the share field.

Anyway, thank you very much for your time and help!

Best Regards,

Daniel


author: Kai Becker
body: Hi [@dahu](/t5/user/viewprofilepage/user-id/5366058)

thanks for the update. I hope the Atlassian Support was able the help and the issue has been resolved.

If so, please make sure to accept an answer to mark the question as resolved.

If it has not been resolved, please feel free to get back with an update.


Tags: cloud

jira-service-management

jira-service-management-cloud