# I want to overwrite entity values in CzmlDataSource

**URL:** <https://community.cesium.com/t/i-want-to-overwrite-entity-values-in-czmldatasource/7664>\
**Category:** CesiumJS\
**Created:** [November 5, 2018, 4:54pm UTC](https://community.cesium.com/t/i-want-to-overwrite-entity-values-in-czmldatasource/7664 "2018-11-05T16:54:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chase\_G](https://avatars.discourse-cdn.com/v4/letter/c/74df32/32.png) [@Chase\_G](https://community.cesium.com/u/Chase_G)\
**Post date:** [November 5, 2018, 4:54pm UTC](https://community.cesium.com/t/i-want-to-overwrite-entity-values-in-czmldatasource/7664/1 "2018-11-05T16:54:57Z")

</div>

Hello All,

I am attempting to overwrite the values of an entity in a CzmlDataSource and having trouble.

I have the following code snippet and when I _console.log_ the **myEntities** I get back the array I am looking for, however I can not seem to access the array and I am not sure why. Anything I try returns undefined, so there is something I am not understanding about Entity or Entity Collections in Cesium. If I log myEntities.length that returns 0 and I am not sure why. I feel like I am missing something really simple here.

const dsOne = new Cesium.CzmlDataSource();

const dsOneUrl = ‘user input: datasource location URL’;

dsOne.load(dsOneUrl);

this.viewer.dataSources.add(dsOne);

const myEntities = dsOne.entities.values;

//this retruns the array I am looking for with all 6 values, however I can not seeem to access it

console.log(myEntities)

//this returns 0

console.log(myEntities.length);

The following is the screenshot of the console for myEntities

![log.png](https://global.discourse-cdn.com/cesium/original/1X/2adb585645d137bb0f37907e0f080178663581e7.png)

Ultimately I am looking to dynamically change the billboard image for my entities which are initially set int the Czml file.

Thanks in advance,

Chase

Using Cesium 1.50, with Chrome on Windows 10

---

<div class="post-metadata">

**Author:** ![Scott\_Hunter](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_hunter/32/2006_2.png) [@Scott\_Hunter](https://community.cesium.com/u/Scott_Hunter)\
**Post date:** [November 5, 2018, 6:53pm UTC](https://community.cesium.com/t/i-want-to-overwrite-entity-values-in-czmldatasource/7664/2 "2018-11-05T18:53:53Z")

</div>

The `load` method is asynchronous, which you can see in the documentation that it returns a Promise.

[https://cesiumjs.org/Cesium/Build/Documentation/CzmlDataSource.html#.load](https://cesiumjs.org/Cesium/Build/Documentation/CzmlDataSource.html#.load)

So you need to wait for load to finish by using .then()

[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)

![log.png](https://global.discourse-cdn.com/cesium/original/1X/2adb585645d137bb0f37907e0f080178663581e7.png)

---

<div class="post-metadata">

**Author:** ![Chase\_G](https://avatars.discourse-cdn.com/v4/letter/c/74df32/32.png) [@Chase\_G](https://community.cesium.com/u/Chase_G)\
**Post date:** [November 5, 2018, 8:15pm UTC](https://community.cesium.com/t/i-want-to-overwrite-entity-values-in-czmldatasource/7664/3 "2018-11-05T20:15:33Z")

</div>

Thank you Scott, and I have seen where you have addressed this previously in other posts (_I have been looking_) but did not fully understand, so thank you for taking the time to assist.  
I have updated the code to the following and expected to see the console.log output, but I do not. If I have misunderstood the documentation references could you please let me know how to resolve this.

const dsOne = new Cesium.CzmlDataSource();

const dsOneUrl = ‘user input: datasource location URL’;

dsOne.load(dsOneUrl).then(function (dataSource) {

this.viewer.dataSources.add(dataSource);

const entities = dataSource.entities.values;

for (let i = 0; i \< entities.length; i++) {

```
   const entity = entities[i];

   console.log(entity);

```

}

});

Regards,

Chase

---

<div class="post-metadata">

**Author:** ![Scott\_Hunter](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_hunter/32/2006_2.png) [@Scott\_Hunter](https://community.cesium.com/u/Scott_Hunter)\
**Post date:** [November 5, 2018, 9:01pm UTC](https://community.cesium.com/t/i-want-to-overwrite-entity-values-in-czmldatasource/7664/4 "2018-11-05T21:01:48Z")

</div>

Most likely your error is in accessing `this.viewer` which is probably undefined from within the callback, which is then throwing an error and halting execution. Rather than relying on console.log for debugging, I would recommend getting familiar with the browser’s JavaScript development tools to set breakpoints and step through your code line-by-line.

---

<div class="post-metadata">

**Author:** ![Chase\_G](https://avatars.discourse-cdn.com/v4/letter/c/74df32/32.png) [@Chase\_G](https://community.cesium.com/u/Chase_G)\
**Post date:** [November 5, 2018, 9:31pm UTC](https://community.cesium.com/t/i-want-to-overwrite-entity-values-in-czmldatasource/7664/5 "2018-11-05T21:31:54Z")

</div>

Scott, Thank you, that was it! I have the objects now.  
Will dig into the dev tools as suggested as well.
