# NetSuite Empty Fields and SQL import

**URL:** <https://connective.celigo.com/t/netsuite-empty-fields-and-sql-import/1484>\
**Category:** Integrator.io\
**Tags:** sql, listener, import, json, netsuite\
**Created:** [July 21, 2020, 3:45pm UTC](https://connective.celigo.com/t/netsuite-empty-fields-and-sql-import/1484 "2020-07-21T15:45:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![psaadmin](https://avatars.discourse-cdn.com/v4/letter/p/8e8cbc/32.png) [@psaadmin](https://connective.celigo.com/u/psaadmin)\
**Post date:** [July 21, 2020, 3:45pm UTC](https://connective.celigo.com/t/netsuite-empty-fields-and-sql-import/1484/1 "2020-07-21T15:45:53Z")

</div>

I am importing to SQL server using a NetSuite listener and an SQL import update query. The query fails, however, if the source data is missing a field. This happens because, apparently, when a field is empty/null in NS, rather than include a "name:empty value" pair, the export for the listener does not include the empty field in the JSON object at all. If I'm using a map, I can specify options if the data is missing, but there's no way to do that in an SQL query. For instance, "isnull()" doesn't work if the field doesn't even exist.

Thanks for any insights!

Jim

---

<div class="post-metadata">

**Author:** ![mattgraney](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/mattgraney/32/6606_2.png) [@mattgraney](https://connective.celigo.com/u/mattgraney)\
**Post date:** [July 21, 2020, 4:02pm UTC](https://connective.celigo.com/t/netsuite-empty-fields-and-sql-import/1484/2 "2020-07-21T16:02:14Z")

</div>

Hi Jim,

You wrote:

_If I'm using a map, I can specify options if the data is missing, but there's no way to do that in an SQL query._

There is in fact a way to do that. In your SQL query builder for the import you can test for missing fields using the {{#if}} handlebar function. If for example you were expecting a field called optionalField, you can test for it as follows, and use its value if it's present, and otherwise use a default.

```
{{#if data.optionalField}}{{data.optionalField}}{{else}}My Default Value{{/if}}
```

Hope that helps!

Matt

---

<div class="post-metadata">

**Author:** ![psaadmin](https://avatars.discourse-cdn.com/v4/letter/p/8e8cbc/32.png) [@psaadmin](https://connective.celigo.com/u/psaadmin)\
**Post date:** [July 21, 2020, 5:51pm UTC](https://connective.celigo.com/t/netsuite-empty-fields-and-sql-import/1484/3 "2020-07-21T17:51:22Z")

</div>

Thank you! I didn't realize handlebar expressions were evaluated in that context beyond simple field substitutions.

Jim

---

<div class="post-metadata">

**Author:** ![mattgraney](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/mattgraney/32/6606_2.png) [@mattgraney](https://connective.celigo.com/u/mattgraney)\
**Post date:** [July 21, 2020, 5:53pm UTC](https://connective.celigo.com/t/netsuite-empty-fields-and-sql-import/1484/4 "2020-07-21T17:53:52Z")

</div>

Glad that worked for you, Jim. That, and more! There are a wide range of macro functions you can use, see [https://docs.celigo.com/hc/en-us/articles/360039326071-Handlebars-Library](https://docs.celigo.com/hc/en-us/articles/360039326071-Handlebars-Library).

-Matt
