Hello, Can anyone point me in the right direction, please. I have Address Input set up on a customer quote form. It picks up the address and places it into a database and shows the address correctly. I set up a sendGrid email to inform us of the customer request. However, the address shows up in the email as Object, Object. ( Address Input is set to a Address in Field Type) Is there a way to parse it across in the email correctly to show the actual request?
Thanks
Here is the sendGrid code I am using for the email response.
$w.onReady(function () {
//TODO: write your page related code here...
let address = $w("#addressInput1").value;
$w("#addressInput1")
;
});
import {sendEmail} from 'backend/email';
$w.onReady(function () {
$w("#dataset1").onAfterSave(sendFormData);
});
function sendFormData() {
const subject = `New Charter Request from ${$w("#input10").value}`;
const body = `New Charter Request: ${$w("#input10").value}
\rFirst Name: ${$w("#input10").value}
\rFrom: ${$w("#addressInput1").value}
\rEmail: ${$w("#input11").value}`;
const recipient = $w("#input11").value;
sendEmail(subject, body)
.then(response => console.log(response));
}
//import {sendEmail, sendEmailWithRecipient} from 'backend/email';
You are getting the error [object Object] because the $w("#address").value is a json object. Console log it to understand the values and use it accordingly in your email.
This is what the .value actually return
/* { * "formatted":"500 Terry A Francois Blvd, San Francisco, CA 94158, USA", * "location": { * "latitude": 37.7703718, * "longitude": -122.38712479999998 * }, * "streetAddress": { * "name": "Terry A Francois Blvd", * "number": "500" * }, * "city": "SF", * "subdivision": "CA", * "country": "US", * "postalCode": "94158" * } */
So if you want to send the address city. You will need to do this.
let address = $w("#address").value; let city = address.city; //use this in your email body like ${city}