Highlighted

Send email via javascript with email body containing data from text input box in Captivate 9?

New Here ,
Mar 07, 2016

Copy link to clipboard

Copied

I have written some code that is activated upon the clicking of a 'submit' button through Execute Javascript. The window.cpAPIInterface.getVariableValue function does not seem to be working. The text entry box has a variable value 'Feedback_Input_Text'. What am I doing wrong? The basic email is sending, with just a normal piece of text, and with: var InputText = "Some Text". But I cannot extract the text entry text. Please help. Thanks!

function log(obj) {

    $('#response').text(JSON.stringify(obj));

}

var m = new mandrill.Mandrill("fG8zVp0HdF_oPuCoa2uYvg");

var InputText = window.cpAPIInterface.getVariableValue("Feedback_Input_Text");

var params = {

    "message": {

        "from_email":"alastair@trnsys.guru",

        "to":[{"email":"alastair.mcdowell@energyae.com"}],

        "subject": "User Feedback",

        "text": InputText

    }

};

function sendTheMail() {

    m.messages.send(params, function(res) {

        log(res);

    }, function(err) {

        log(err);

    });

}

Views

695

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Send email via javascript with email body containing data from text input box in Captivate 9?

New Here ,
Mar 07, 2016

Copy link to clipboard

Copied

I have written some code that is activated upon the clicking of a 'submit' button through Execute Javascript. The window.cpAPIInterface.getVariableValue function does not seem to be working. The text entry box has a variable value 'Feedback_Input_Text'. What am I doing wrong? The basic email is sending, with just a normal piece of text, and with: var InputText = "Some Text". But I cannot extract the text entry text. Please help. Thanks!

function log(obj) {

    $('#response').text(JSON.stringify(obj));

}

var m = new mandrill.Mandrill("fG8zVp0HdF_oPuCoa2uYvg");

var InputText = window.cpAPIInterface.getVariableValue("Feedback_Input_Text");

var params = {

    "message": {

        "from_email":"alastair@trnsys.guru",

        "to":[{"email":"alastair.mcdowell@energyae.com"}],

        "subject": "User Feedback",

        "text": InputText

    }

};

function sendTheMail() {

    m.messages.send(params, function(res) {

        log(res);

    }, function(err) {

        log(err);

    });

}

Views

696

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Jan 27, 2020

Copy link to clipboard

Copied

I'm looking to do the same thing. Any luck with getting the code to work?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Jan 28, 2020

Copy link to clipboard

Copied

Are you getting any errors in the browser console?

 

Try logging the variable.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Participant ,
Jan 29, 2020

Copy link to clipboard

Copied

Did you create the variable as a user variable in CP or is it just declared in the JS code?

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Resources
Captivate User Guide
New Group