Update Asset Attribute via Automation - Date Field
Asked by Nicole Br?ckner:

Dear Community,

I try to update an Asset Object via Automation (provided by Scriptrunner).

In

* customfield_19103 is the asset object referenced and in
* customfield_16512 is the date, which will be maintained in the ticket.

I don't know the right format for date array in json. Can you please help?

```
{
"objectKey": {{issue.customfield_19103.key.asJsonString}},
"Submission Date": {{issue.customfield_16512.date.asJsonArray}}
}
```

Best regards-,

Nicole![2024-04-25 17_07_01-Automation - Nexus AG - Jira und 15 weitere Seiten - Gesch?ftlich ? Microsoft? E.png](https://community.atlassian.com/t5/image/serverpage/image-id/320629i3235B65B92EBE319/image-size/large?v=v2&px=999 "2024-04-25 17_07_01-Automation - Nexus AG - Jira und 15 weitere Seiten - Gesch?ftlich ? Microsoft? E.png")


Answers:
author: Ram Kumar Aravindakshan _Adaptavist_
body: Hi [@Nicole Br?ckner](/t5/user/viewprofilepage/user-id/4451755)

From the configuration you have shared, I suspect this will not work.

Currently, you are passing the value into the Submission Date attribute as an array, i.e.:-

```
"Submission Date": {{issue.customfield_16512.date.asJsonArray}}
```

Could you please try to modify your configuration to a String, i.e.:-

```
{
"objectKey": {{issue.customfield_19103.key.asJsonString}},
"Submission Date": {{issue.customfield_16512.date.asJsonString}}
}
```

And see if it works.

I am looking forward to your feedback.

Thank you and Kind regards,

Ram

comments: author: Nicole Br?ckner
body: Hi [@Ram Kumar Aravindakshan _Adaptavist_](/t5/user/viewprofilepage/user-id/2988015)

Thanks for the effort. With string the same error message appears:  
Unexpected error executing rule:  
Could not parse input as JSON. Input after smart values applied was: '{ "objectKey": "NXSPCRM-236126", "Submission Date": }'  
Is there any issue in regards of the Timing unit?  
In Asset we have dd.mm.yy and in Jira we have dd.mm.yyyy  
Could this be point?  
Best-,  
Nicole


author: Ram Kumar Aravindakshan _Adaptavist_
body: Hi [@Nicole Br?ckner](/t5/user/viewprofilepage/user-id/4451755)

From the error message returned it seems that an empty value is entered in the Submission Date.

```
Could not parse input as JSON. Input after smart values applied was: '{ "objectKey": "NXSPCRM-236126", "Submission Date": }'
```

Please confirm if the value is entered for the submission date.

It would be helpful if you could share a screenshot of the date field you are trying to pass and also the structure of your Asset object.

You also asked:-
> Is there any issue in regards of the Timing unit?  
> In Asset we have dd.mm.yy and in Jira we have dd.mm.yyyy  
> Could this be point?

This could also be possible. It would be good to set the format in the Asset date to match your Jira date format and retest it.

Thank you and Kind regards,  
Ram


author: Nicole Br?ckner
body: Dear [@Ram Kumar Aravindakshan _Adaptavist_](/t5/user/viewprofilepage/user-id/2988015)

I fixed this

* Add "fields" into the Submission Date Line
* with putting the Date into ""

{  
"objectKey": {{issue.customfield_19103.key.asJsonString}},  
"Submission Date": "{{issue.fields.customfield_16512}}"  
}

Thanks for the help.

Nicole


Tags: assets

automation

jira-service-desk-data-center

jira-service-management

jira-service-management-data-center

scriptrunner