# Help with setFieldValue

**URL:** <https://forum.wixstudio.com/t/help-with-setfieldvalue/10579>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [July 6, 2018, 7:35am UTC](https://forum.wixstudio.com/t/help-with-setfieldvalue/10579 "2018-07-06T07:35:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ikeda](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ikeda/32/5355_2.png) [@ikeda](https://forum.wixstudio.com/u/ikeda)\
**Post date:** [July 6, 2018, 7:35am UTC](https://forum.wixstudio.com/t/help-with-setfieldvalue/10579/1 "2018-07-06T07:35:25Z")

</div>

I have a item dynamic page where I made a form.  
I’ll hide one of the fields and it must contain the same text of #text6 before save the form.

I’m really bad in JavaScript and have no clue where is the mistake.

The code is:

export function button1\_click(event, $w)  
{  
$w(“#dataset1”).setFieldValue(“codMold”, $w(‘#text6’));

}

But the content of the field comes [object Object]

I know probaly it’s a dumb mistake, but I’ve tried everything i know =(

I 'll really apreciate if some one help =)

---

<div class="post-metadata">

**Author:** ![211026a](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/211026a/32/4120_2.png) [@211026a](https://forum.wixstudio.com/u/211026a)\
**Post date:** [July 6, 2018, 10:57am UTC](https://forum.wixstudio.com/t/help-with-setfieldvalue/10579/2 "2018-07-06T10:57:23Z")

</div>

Try so:  
(“codMold”: $w(’ [#text6](https://www.wix.com/code/home/forum/search/posts%3Fquery=%23text6) '))

---

<div class="post-metadata">

**Author:** ![ikeda](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ikeda/32/5355_2.png) [@ikeda](https://forum.wixstudio.com/u/ikeda)\
**Post date:** [July 6, 2018, 4:51pm UTC](https://forum.wixstudio.com/t/help-with-setfieldvalue/10579/3 "2018-07-06T16:51:23Z")

</div>

Didn’t work =(

---

<div class="post-metadata">

**Author:** ![ikeda](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/ikeda/32/5355_2.png) [@ikeda](https://forum.wixstudio.com/u/ikeda)\
**Post date:** [July 6, 2018, 5:48pm UTC](https://forum.wixstudio.com/t/help-with-setfieldvalue/10579/4 "2018-07-06T17:48:22Z")

</div>

I figured it out after a day trying!!!

The code who works it’s

export function button1\_click\_1(event, $w)  
{  
//Add your code for this event here:  
$w(‘#dataset1’).setFieldValue(“codMold”, $w(‘#text6’).text);  
}

Hope to help someone with this information… one day it’s too much time to waste

---

<div class="post-metadata">

**Author:** ![tumalopete](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/tumalopete/32/2546_2.png) [@tumalopete](https://forum.wixstudio.com/u/tumalopete)\
**Post date:** [September 22, 2019, 11:02pm UTC](https://forum.wixstudio.com/t/help-with-setfieldvalue/10579/5 "2019-09-22T23:02:30Z")

</div>

Your post saved me days of frustration. Thank You!

---

<div class="post-metadata">

**Author:** ![brian39460](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/brian39460/32/10317_2.png) [@brian39460](https://forum.wixstudio.com/u/brian39460)\
**Post date:** [September 28, 2019, 5:35pm UTC](https://forum.wixstudio.com/t/help-with-setfieldvalue/10579/6 "2019-09-28T17:35:26Z")

</div>

You just saved me too. As a rookie here, I would have never even thought of that.

---

<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:** [September 28, 2019, 8:51pm UTC](https://forum.wixstudio.com/t/help-with-setfieldvalue/10579/7 "2019-09-28T20:51:26Z")

</div>

Look in the Wix API Reference and it would have given you the answer straight away, along with code samples for it too.

[https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#setFieldValue](https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#setFieldValue)

---

<div class="post-metadata">

**Author:** ![211026a](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/211026a/32/4120_2.png) [@211026a](https://forum.wixstudio.com/u/211026a)\
**Post date:** [September 28, 2019, 10:22pm UTC](https://forum.wixstudio.com/t/help-with-setfieldvalue/10579/8 "2019-09-28T22:22:18Z")

</div>

Givemeawhisky (thanks to him) advised to look in the Wix API Reference. There is a very important rule: “Setting the value of a field in a dataset item does not immediately set that value in the collection that the dataset is connected to. You still need to call the dataset save() function or any other function that performs a save to have the new value reflecting in the collection. "  
Therefore add: $w (”#dataset1"). save ();
