Hello,
I’ve a database connected to a repeater and I would like to send an email to the member when there is a new content into the repeater.
I’ve already create the automation mail and the ID is in the code.
$w.onReady( () => {
$w("#dataset4").onReady( () => {
$w("#dataset4").refresh()
.then( () => {
console.log("Done refreshing the dataset");
} );
$w("#dataset4").onCurrentIndexChanged( (index) => { // I WOULD LIKE TO KNOW IF THERE IS A NEW INDEX
let newIndex = index; // 3
console.log("index " ,index);
//HERE I WOULD LIKE TO CREATE A CODE, IF THERE IS A NEW INDEX SEND THE MAIL TO THE MEMBER
wixUsers.emailUser('S8yc95j', );
} );
} );
} );
If you have code to share, then please post here. Please do not force users to sign up on your website to see an example project or code. A signup should be optional, or to gain access to more advanced content.
@yisrael-wix
Ok, normaly there is no sign-up needed. This is just in few examples the situation, because of the behaviour of PrivateMembersData. This example can’t work without a sign-up / log-in.
I’ve updated my code, but Can you help me please.
$w.onReady( () => {
$w("#dataset4").onReady( () => {
$w("#dataset4").refresh()
.then( () => {
//console.log("Done refreshing the dataset");
} );
$w("#dataset4").onItemValuesChanged( (itemBeforeChange, updatedItem) => {
console.log("BEFORE " , itemBeforeChange, "AFTER ", updatedItem);
} );
$w("#dataset4").onCurrentIndexChanged( (index) => {
//console.log ("OH - dataset4.onCurrentIndexChanged", index);
} );
/*
$w("#dataset4").onCurrentIndexChanged( (index) => { // I WOULD LIKE TO KNOW IF THERE IS A NEW INDEX
let newIndex = index; // 3
console.log("index " ,dataset4.onCurrentIndexChanged);
//HERE I WOULD LIKE TO CREATE A CODE, IF THERE IS A NEW INDEX SEND THE MAIL TO THE MEMBER
//wixUsers.emailUser('S8yc95j', );
} );*/
} );
} );
This is the triggered-Email-Part…
Modify the KEY and your setted-up “trigger-Email”- address .
import wixUsers from 'wix-users';
import wixCrm from 'wix-crm';
$w.onReady(function () { });
//-----------------------------------------------------------------------------------------
export function button1_click(event) {send_Email ()} //<---starts the eMail-process!
//-----------------------------------------------------------------------------------------
function send_Email (parameter) {
let userId = wixUsers.currentUser.id;
let value1 = "russian-dima@hotmail.de" //<------ change this to your own E-Mail
console.log(userId)
console.log((value1))
wixUsers.emailUser("test", userId, { //"test" ---> KEY ! ! ! !
"variables": { //variables which you have setted-up in your triggered email!
"variable1": value1, //variables which you have setted-up in your triggered email!
"variable2": "value for variable2" //variables which you have setted-up in your triggered email!
}
} )
.then( () => {
console.log("Triggered email sent");
} )
.catch( (err) => {
console.log(err);
} );
console.log(("Job done!"))
console.log("Triggered-Test-Mail succsselfully sent. Delivery in about 15sec.")
}