Custom field retrieval in contacts using user input form

Hi,

Have created a custom field called empid in the contact list. If we want to pull the data of custom field. I did this way

let userEmpId = user.empid;
$w(“#empid”).value= “” + userEmpId;

Its not throwing any error but it says undefined in the userinput form

Please help me

You’ll need to provide more code for us to be able to figure out what you’re doing. What is user? What is empid? What is undefined? And by the way - that’s an error.

Hi YIsrael,

In Contacts a member who has logged in. I have added a custom field called empid. Please find below.

Like how we are able to retrieve the _id, email from Contact & CRM. How can we fetch the empid which I have added as custom field. I want this retrieve in the user form and code is shown below

import wixUsers from ‘wix-users’;

$w.onReady(function () {
let user = wixUsers.currentUser;

let userId = user.id; // “r5cme-6fem-485j-djre-4844c49”
let isLoggedIn = user.loggedIn; // true
let userRole = user.role; // “Member”
let userEmpId = user.empid;

user.getEmail()
.then( (email) => {
let userEmail = email; // “user@something.com
let status= “Open”;
$w(“#email”).value= “” + userEmail;
$w(“#dataset1”).setFieldValue(“requestedby”, userEmail);
$w(“#status”).value= “” + status;
$w(“#dataset1”).setFieldValue(“status”, status);
$w(“#empid”).value= “” + userEmpId;

} );

});

This is the code

This is the published page. Its not showing error in Builder. It just says Undefined. Highlighted in Yellow

Any help