# How to insert a reference by code? 


**URL:** <https://forum.wixstudio.com/t/how-to-insert-a-reference-by-code/22709>\
**Category:** Ask the community\
**Tags:** wix-members-area, code, question\
**Created:** [May 7, 2020, 7:28pm UTC](https://forum.wixstudio.com/t/how-to-insert-a-reference-by-code/22709 "2020-05-07T19:28:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anthonybasang18](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/anthonybasang18/32/18961_2.png) [@anthonybasang18](https://forum.wixstudio.com/u/anthonybasang18)\
**Post date:** [May 7, 2020, 7:28pm UTC](https://forum.wixstudio.com/t/how-to-insert-a-reference-by-code/22709/1 "2020-05-07T19:28:26Z")

</div>

I have two collections “Project” and “Members”.  
The “Members” collection have Reference field named" My Project" connecting to “Project” collection  
The site member(author) can create a project and add members into it  
Now I want to display a specific project with their members  
The site member(author) can have multiple projects with the same or different members  
I’m able to display the Project with specific members since I have the reference field “My Project”  
in that way I able to filter out the members in a same project  
The problem is I do it manually, adding the specific project(reference) into “My Project”(reference field inside “Members” collection

1. Is there a way to automatically insert a reference in the reference field of a Collection?
2. What is the data type does reference field accepts is the Primary key or the ID(system generated) of an item?
3. How do I get the reference value and add to the Reference Field

I new with web development especially with the wix api

Hopefully, you can help me  
thank you

---

<div class="post-metadata">

**Author:** ![tony-brunsman](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@tony-brunsman](https://forum.wixstudio.com/u/tony-brunsman)\
**Post date:** [May 7, 2020, 8:15pm UTC](https://forum.wixstudio.com/t/how-to-insert-a-reference-by-code/22709/2 "2020-05-07T20:15:44Z")

</div>

@anthonybasang18 Have a look at these functions. It will take some trial and error, but you will get the idea of how they work.

[https://www.wix.com/corvid/reference/wix-data.html#insertReference](https://www.wix.com/corvid/reference/wix-data.html#insertReference)  
[https://www.wix.com/corvid/reference/wix-data.html#replaceReferences](https://www.wix.com/corvid/reference/wix-data.html#replaceReferences)  
[https://www.wix.com/corvid/reference/wix-data.html#removeReference](https://www.wix.com/corvid/reference/wix-data.html#removeReference)

---

<div class="post-metadata">

**Author:** ![anthonybasang18](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/anthonybasang18/32/18961_2.png) [@anthonybasang18](https://forum.wixstudio.com/u/anthonybasang18)\
**Post date:** [May 7, 2020, 9:46pm UTC](https://forum.wixstudio.com/t/how-to-insert-a-reference-by-code/22709/3 "2020-05-07T21:46:40Z")

</div>

I tried to read that but I still don’ t get it  
But I will try to conduct some experiments
