# Is it possible to use insertReference inside a hook?

**URL:** <https://forum.wixstudio.com/t/is-it-possible-to-use-insertreference-inside-a-hook/25307>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [February 18, 2020, 9:41pm UTC](https://forum.wixstudio.com/t/is-it-possible-to-use-insertreference-inside-a-hook/25307 "2020-02-18T21:41:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![boazalbert](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/boazalbert/32/9377_2.png) [@boazalbert](https://forum.wixstudio.com/u/boazalbert)\
**Post date:** [February 18, 2020, 9:41pm UTC](https://forum.wixstudio.com/t/is-it-possible-to-use-insertreference-inside-a-hook/25307/1 "2020-02-18T21:41:36Z")

</div>

I’m trying to insert a reference field to a collection using a hook - the data is coming from outside the website, so I can’t do it via the page’s code itself. I tried with insertReference, and I also tried by updating the relevant item property with the \_id of the referenced item - nothing works.

---

<div class="post-metadata">

**Author:** ![givemeawhisky](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/givemeawhisky/32/5383_2.png) [@givemeawhisky](https://forum.wixstudio.com/u/givemeawhisky)\
**Post date:** [February 18, 2020, 11:56pm UTC](https://forum.wixstudio.com/t/is-it-possible-to-use-insertreference-inside-a-hook/25307/2 "2020-02-18T23:56:28Z")

</div>

Without knowing what your outside usage is for your external data, have you looked into the Wix option of using an external dataset within your site?  
[https://www.wix.com/corvid/reference/external-database-collections.html](https://www.wix.com/corvid/reference/external-database-collections.html)  
[https://support.wix.com/en/article/corvid-adding-and-deleting-an-external-database-collection](https://support.wix.com/en/article/corvid-adding-and-deleting-an-external-database-collection)  
[https://support.wix.com/en/article/corvid-working-with-external-database-collections](https://support.wix.com/en/article/corvid-working-with-external-database-collections)

As it does mention in that last link above that you can work with single references in your external dataset, however you can’t use multiple item reference fields.  
[https://support.wix.com/en/article/corvid-working-with-external-database-collections#working-with-reference-fields](https://support.wix.com/en/article/corvid-working-with-external-database-collections#working-with-reference-fields)

**Working with reference fields**  
You cannot work with [multiple item reference fields](https://support.wix.com/en/article/working-with-multiple-item-reference-fields) in external database collections. You can only use single references in external databases, with the following implementation rules:

- The reference must point to an \_id field.

- The reference field must be of type string.

- To allow references from other collections to the external collection the \_id field needs to accept the hasSome filter.
