Hello there,
I have the following code that is working just fine, it sends the dataset values to the email provided but now I need to send the same values to one or two new emails that do not belong to the dataset.
The current code (working fine):
let name;
import wixUsers from ‘wix-users’ ;
import wixData from ‘wix-data’ ;
$w.onReady( function () {
wixData.query( “Members/PrivateMembersData” )
.eq( “_id” , wixUsers.currentUser.id)
.find()
.then((results) => {
$w( "#lawyerName" ).value = results.items[ 0 ].name;
name = results.items[ 0 ].name;
//console.log(results.items[0].name);
})
$w( “#dataset1” ).onAfterSave( () => {
if (wixUsers.currentUser.loggedIn) {
//console.log(name);
const userId = wixUsers.currentUser.id;
wixUsers.emailUser( ‘RyEca9M’ , userId, {
variables: {
//“attorneyName”: name,
“attorneyName” : $w( “#lawyerName” ).value, // THIS FIELD IS NOT SAVED IN THE DATASET!!!
“clientName” : $w( “#firstName” ).value,
“clientLastName” : $w( “#lastName” ).value,
“clientPhone” : $w( “#clientPhone” ).value,
“clientEmail” : $w( “#clientEmail” ).value,
//“clientAddress”: $w(“#addressInput”).value,
“typeOfAccident” : $w( “#typeAccident” ).value,
“additionalInfo” : $w( “#AditionalInfo” ).value
}
} )
.then( () => {
console.log( “Triggered email sent” );
//console.log(name);
} )
. catch ( (err) => {
console.log( “Triggered email NOT SEND!” );
} );
}
} );