This topic is locked

User enters subject, email body, "from" email address

9/11/2015 3:31:58 PM
PHPRunner General questions
V
vic4nze author

Hi, I tried to implement email selected users and tried to replicate exactly what was described in the documentation here User enters subject, email body, "from" email address but it does't seem to work PHPRunner8.0.
Note: I copied the code as it was written verbatim just to see the functionality and it's not popping up.
Any suggestion please.

lefty 9/11/2015



Hi, I tried to implement email selected users and tried to replicate exactly what was described in the documentation here User enters subject, email body, "from" email address but it does't seem to work PHPRunner8.0.
Note: I copied the code as it was written verbatim just to see the functionality and it's not popping up.
Any suggestion please.



Post your button before , server , after code ?

V
vic4nze author 9/12/2015



Post your button before , server , after code ?


This is what I have before:

if ( proxy["emailUsers"] === true ) {
params["emailFrom"] = proxy["emailFrom"];
params["emailBody"] = proxy["emailBody"];
params["emailSubject"] = proxy["emailSubject"];

delete( proxy["emailUsers"] );
delete( proxy["emailFrom"] );
delete( proxy["emailBody"] );
delete( proxy["emailSubject"] );

return true;
}

var selBoxes = pageObj.getSelBoxes( pageid ),
args = {
modal: true,
centered: true,
headerContent: "Input from, subject and body",
bodyContent: '<div>'
+ '<div>From:&nbsp;<input type="text" id="emailFrom"s style="margin: 5px 0"></input></div>'
+ '<div>Subject:&nbsp;<input type="text" id="emailSubject"s style="margin: 5px 0"></input></div>'
+ '<div>Body:&nbsp;<textarea id="emailBody"></textarea></div>'
+ '</div>'
};

if ( selBoxes.length == 0 || !confirm('Do you really want to email these records?') ) {
return false;
}

Runner.pages.PageManager.createFlyWin( args, false, function( win ) {
var Y = Runner.Y;

win.bodyNode.setStyle("textAlign", "center");

win.addButton({
label : Runner.lang.constants.TEXT_SAVE,
name : "saveButton",
template: "<a />",
classNames : "rnr-button main",
section: Y.WidgetStdMod.FOOTER,
action : function (e) {
var bodyDomNode = win.bodyNode.getDOMNode();

proxy["emailUsers"] = true;
proxy["emailFrom"] = $("#emailFrom", bodyDomNode).val();
proxy["emailBody"] = $("#emailBody", bodyDomNode).val();
proxy["emailSubject"] = $("#emailSubject", bodyDomNode).val();
$('[id^="' + params["buttId"] + '"]').click();

e.preventDefault();
win.destroy( true );
}
});

win.addButton({
label : Runner.lang.constants.TEXT_CANCEL,
template: "<a />",
classNames : "rnr-button",
section: Y.WidgetStdMod.FOOTER,
action : function (e) {
e.preventDefault();
win.destroy( true );
}
});

Runner.pages.PageManager.correctYUIWindowSize( "", 0, true, win );
});

return false;


This is what I have on server, my email address field is called "email":

if( $params["emailBody"] || $params["emailSubject"] || $params["emailFrom"] )
{
$emails = array();
while ( $data = $button->getNextSelectedRecord() )
{
if ( $data["email"] )
$emails[] = $data["email"];
}

// send the email
$from = $params["emailFrom"];
$email = implode(",", $emails);
$body = $params["emailBody"];
$subject = $params["emailSubject"];
$arr = runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $body, 'from' => $from));

$result["txt"] = "Emails were sent.";
if (!$arr["mailed"])
{
$errmsg = "Error happened:
";
$errmsg.= "File: " . $arr["errors"][0]["file"] . "
";
$errmsg.= "Line: " . $arr["errors"][0]["line"] . "
";
$errmsg.= "Description: " . $arr["errors"][0]["description"] . "
";
$result["txt"] = $errmsg;
}
}



This what I have after:

// Put your code here.

var message = result["txt"] + " !!!";

ctrl.setMessage(message);


I get the dialogue "Do you really want to email these records?" but when I click ok nothing happens. I aslo see this JS error in Property inspector "Uncaught TypeError: Cannot read property 'getDOMNode' of undefined"
Any suggestions?