let contactId = results.body.results[0].id; // Id of the referring contact
let referred_by = results.body.results[0].properties.firstname + " " + results.body.results[0].properties.lastname;
}
The referrer_ variable contains the correct value but the doSearch never returns any results. I’ve also tried just searching for the contact by email with the correct email hardcoded into the query but i still receive nothing back. Is there something else i should be doing?
Hi, @LDev7 Let’s dig into the search operator part of things, and we can go from there
The EQ filter is strict. Unless you literally have a Contact with an exact value of “referrer_” for the Referrer ID property, I’m not surprised it’s coming back with zero results.
Can you try the CONTAINS_TOKEN operator instead, please?
I ran a quick test and got back a successful result.
PS, I made a few assumptions on your exact setup, but I think I got close:
I created a custom property called “referrer id” and gave it an internal value of referrer_id
I assigned this property to three contacts. Not only that, but I wasn’t certain if you were concatenating an additional string to each Contact’s value for the property — meaning I chose to do it like “referrer_id_123”, for example.
Thanks for the reply. The referrer_ value is a variable that is assigned a value from the input field. In this case a 5 digit number. This number matches exactly with the referrer_id property on the contact record.
This appears to be working now. The issue i now have is retrieving the data from the results. I would like the firstname property in the result to add to a variable.
An example i had been given was to use: let referred_by = results.body.results[0].properties.firstname
but when doing this i get this error
"errorMessage":"TypeError: Cannot read properties of undefined (reading 'results')"
If i just do a console.log of the results i get this: