Hi, I’m trying to get the values from the custom fields of a website user.
In here, there is the custom field named “Nombre de Mesa” so I would like to get the value “AG4” in my code.
I’ve try this but I don’t know how to continue.
import wixCrm from 'wix-crm';
let customField = wixCrm.ContactInfo.customFields.nombreDeMesa;
I suppose it’s wrong but I don’t know how to continue.
Thanks.
Okay so you have added custom fields as like here.
[Adding Custom Fields to Contacts | Help Center | Wix.com](Adding Custom Fields to Contacts | Help Center | Wix.com
So)
Then you have made up your own user input form for the user to submit data into these custom fields etc.
Therefore, you can simply query that dataset used to get the custom field info and display that in either another user input or a text box on your page.
Assuming that your users are logged in site members…
Something like one of these two below and just make sure that you only use the one choice for the custom field, either the user input that uses value or the text box that uses text.
import wixUsers from 'wix-users';
import wixData from 'wix-data';
$w.onReady(function () {
wixData.query("yourdatasetname")
.eq("_id", wixUsers.currentUser.id)
.find()
.then((results) => {
$w('#customField').value = results.items[0].nombreDeMesa;
$w('#customField').text = results.items[0].nombreDeMesa;
});
});
import wixUsers from 'wix-users';
import wixData from 'wix-data';
$w.onReady(function () {
let currentUser = wixUsers.currentUser;
currentUser.getEmail().then(email => {
wixData.query("yourdatasetname")
.eq("email", email)
.find()
.then((results) => {
$w('#customField').value = results.items[0].nombreDeMesa;
$w('#customField').text = results.items[0].nombreDeMesa;
});
});
});
If they are not site members and are just users who have contacted you, then you would have to look at using code through the Wix CRM Backend API and get the info through the use of getContactbyId function.
https://www.wix.com/corvid/reference/wix-crm-backend.html#getContactById
I’ll use it on a privated members page, so all will be loged in.
Thank You so much.
But from which dataset I will do they query?
I used the Prívate Members info but it didnt get the custom value.
hello, diego_deap
can you please help me how you get the result
@iwwkajol
Page code
import { myBackendFunction } from 'backend/GetSucursal';
wixData.query("Members/PrivateMembersData")
.eq("_id", wixUsers.currentUser.id)
.find()
.then((result) => {
var idcontact = result.items[0].contactId;
myBackendFunction(idcontacto)
.then((res) => {
console.log(res); //The information you want to get from the CRM
});
});
Backend code //GetSucursal.jsw
import wixCrmBackend from 'wix-crm-backend';
export function myBackendFunction(idcontacto) {
return wixCrmBackend.getContactById(idcontacto);
}
Thank You so much diego_deap .
you save my day 
Hi, What does var idcontact = result . items [ 0 ]. contactId ; do exactly?
I have the same sort of pb. I have created a custom signup form, and I want the members to be able to update it via a private page . My understanding is that everything that it not in the members database is stored in the contact list (unless I create my own collection, which I don’t). I want to access the informations in the contactList . I know how to access the member’s id and email, but I don’t know how to use the getContact() and store the values I am looking for. Any help would be greatly appreciated other than the Wix getContact() help page. Thanks
Every registered user will be stored in the wix-crm (Contact-List) after successful registration (with all user’s entered data and pic).
Do not use the old → getContact()-API because it is DEPRICATED and some day will surely be eleted completely.
Insted of the old one use this one…(the new one)…
https://www.wix.com/velo/reference/wix-crm-backend/contacts-obj/getcontact
You do not need the PrivateMembersDatabase.
thanks for replying but this is in detail what I am trying to do:
when the members register, they are asked for some choices of newsletters.
I want them to be able to update those choices latter on, with a member page.
So first I need to find the user in the contactlist, retrieve his first choices and check the corresponding checkboxes on the screen so he can see what were his first choices.Then i have to accept the changes and update the contactlist.
I have seen the example in the wix help of the updateMyContactsFunction() but have no idea on where and how to manage the #checkbox1,2 and3 that I have on my form. I really need help… thanks