# Accessing datafields in javascript(when sending a mail)

**URL:** <https://community.appfarm.io/t/accessing-datafields-in-javascript-when-sending-a-mail/2199>\
**Category:** Ask the community\
**Created:** [December 31, 2025, 3:08pm UTC](https://community.appfarm.io/t/accessing-datafields-in-javascript-when-sending-a-mail/2199 "2025-12-31T15:08:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobias.nygard](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/tobias.nygard/32/2823_2.png) [@tobias.nygard](https://community.appfarm.io/u/tobias.nygard)\
**Post date:** [December 31, 2025, 3:08pm UTC](https://community.appfarm.io/t/accessing-datafields-in-javascript-when-sending-a-mail/2199/1 "2025-12-31T15:08:23Z")

</div>

Hello.  
I am working with a mail, where I have “tilbud” as a list of different “tilbud” in function params. In this mail I want to list the names of companies that the “tilbud” has been sent to, but the field returns as undefined. Here’s the code:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/3/30d1d0363fb86ccdc308f7dca8b51fefb28415c1.png)

I can access tilbud.leverandor, meaning it prints the ID of it, but tilbud.leverandor.navn does not work.

Is there any workarounds for this?

---

<div class="post-metadata">

**Author:** ![kristian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/kristian/32/58_2.png) [@kristian](https://community.appfarm.io/u/kristian)\
**Post date:** [January 1, 2026, 12:05am UTC](https://community.appfarm.io/t/accessing-datafields-in-javascript-when-sending-a-mail/2199/2 "2026-01-01T00:05:42Z")

</div>

Hi,

And happy new year!

You cannot access deep properties when adding whole datasources as function params. See the «Good to know» section here:

> **[Return a single value from an array - Functions | Appfarm Documentation](https://docs.appfarm.io/reference/platform-concepts/functions#return-a-single-value-from-an-array)**
>
> With functions, you can express advanced conditions or calculations using JavaScript. The JavaScript code is sandboxed and has read-only access to the data sources defined as parameters.

---

<div class="post-metadata">

**Author:** ![tobias.nygard](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/tobias.nygard/32/2823_2.png) [@tobias.nygard](https://community.appfarm.io/u/tobias.nygard)\
**Post date:** [January 2, 2026, 3:09pm UTC](https://community.appfarm.io/t/accessing-datafields-in-javascript-when-sending-a-mail/2199/3 "2026-01-02T15:09:17Z")

</div>

Ok so if I understood right I just add a runtime property on Tilbud of datatype String, and use a function:

> return leverandor.navn

using the self property leverandor.  
This didn’t work at least, so I ended up just iterating through all companies and if the ID matched tilbud.leverandor, I returned selskap.navn. Not very efficient, but works for now.

Thanks for the help, happy new year:)
