# How Do I Set a Value on an Associated (belongsTo) Record?

**URL:** <https://discuss.emberjs.com/t/how-do-i-set-a-value-on-an-associated-belongsto-record/3907>\
**Category:** Ember Data\
**Created:** [January 19, 2014, 7:59pm UTC](https://discuss.emberjs.com/t/how-do-i-set-a-value-on-an-associated-belongsto-record/3907 "2014-01-19T19:59:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattapayne](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/mattapayne/32/15439_2.png) [@mattapayne](https://discuss.emberjs.com/u/mattapayne)\
**Post date:** [January 19, 2014, 7:59pm UTC](https://discuss.emberjs.com/t/how-do-i-set-a-value-on-an-associated-belongsto-record/3907/1 "2014-01-19T19:59:49Z")

</div>

Hi,

I’m probably missing something really obvious, but I can’t figure it out …

I have 2 models:

Session & Content

Content “belongsTo” Session, so each Session instance has a “content” property. The relationship is async.

What I’m trying to do is this:

When I navigate to the session route, I want to set the value of a property on the session’s content. It seems, however, that the content is never available to have anything set, though.

Using the Ember Chrome debugger, I can see that the session object does, in fact, have a content property. When I click on it, it shows that it’s a PromiseObject. Clicking further eventually gets me to the content object itself.

So I know that because it’s loaded async, it won’t be available immediately.

My question is: How or when do I know that I have the actual, resolved content object loaded so that I can set one of its properties?

Sorry if this is unclear. I can provide more information if necessary.

Thanks, Matt

---

<div class="post-metadata">

**Author:** ![gordon\_kristan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/gordon_kristan/32/14862_2.png) [@gordon\_kristan](https://discuss.emberjs.com/u/gordon_kristan)\
**Post date:** [January 20, 2014, 2:31pm UTC](https://discuss.emberjs.com/t/how-do-i-set-a-value-on-an-associated-belongsto-record/3907/2 "2014-01-20T14:31:33Z")

</div>

You just need to use the `then` method of the promise. It takes two parameters: the first is a function to execute if the data is successfully fetched, the second is an error function.

```
foo.get('relationship').then(function(value) {
    value.set('key', 'value');
}, function(error) {
    console.log('The promise failed');
    console.log(error);
});

```

---

<div class="post-metadata">

**Author:** ![mattapayne](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/mattapayne/32/15439_2.png) [@mattapayne](https://discuss.emberjs.com/u/mattapayne)\
**Post date:** [January 20, 2014, 5:08pm UTC](https://discuss.emberjs.com/t/how-do-i-set-a-value-on-an-associated-belongsto-record/3907/3 "2014-01-20T17:08:18Z")

</div>

Thanks Gordon!

I came to the same conclusion and was about to reply to myself. Appreciate the help!

Matt
