# Painless updating Array of custom objects

**URL:** https://discuss.elastic.co/t/painless-updating-array-of-custom-objects/165527
**Category:** Elasticsearch
**Tags:** painless
**Created:** [January 24, 2019, 5:17am UTC](https://discuss.elastic.co/t/painless-updating-array-of-custom-objects/165527 "2019-01-24T05:17:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Rashid\_Yes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashid_yes/32/45796_2.png) [@Rashid\_Yes](https://discuss.elastic.co/u/Rashid_Yes)
#### Post date: [January 24, 2019, 5:17am UTC](https://discuss.elastic.co/t/painless-updating-array-of-custom-objects/165527/1 "2019-01-24T05:17:19Z")

</div>

Painless updating Array of custom objects

But below script is not working. Please let me know the solution:

code = "ctx.\_source.attachments.add([" +  
""attachmentId" : params.attachmentId," +  
""size" : params.size," +  
""type" : params.type," +  
""file\_name" : params.file\_name" +  
"]);";

Below is working fine:  
{  
"script": {  
"inline": "ctx.\_source.attachments.add(["first" : params.first, "last" : params.last]);",  
"params": {  
"first": "123", "last": "456"  
}  
}  
}

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [February 21, 2019, 5:17am UTC](https://discuss.elastic.co/t/painless-updating-array-of-custom-objects/165527/2 "2019-02-21T05:17:21Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
