This topic is locked

Edit Page Dialog issues

3/10/2021 10:37:05 AM
PHPRunner General questions
R
RBrogen author

Hey Everyone,

I'm having an issue with the code below not executing when on an Edit page. The purpose of the button code is to create a pdf of the document they are on and send it to the email in the system. I have also tested doing just a Runner.PDF.download option and I get the same error. Any assistance/guidance would be greatly appreaciated.
ERROR:

Uncaught TypeError: Cannot read property 'replace' of undefined

at Object.Runner.displayGenericAjaxError (RunnerAll.js?36520:204)

at Object.success (RunnerAll.js?36520:2925)

at j (loadfirst.js?36520:1)

at Object.fireWith [as resolveWith] (loadfirst.js?36520:1)

at x (loadfirst.js?36520:1)

at XMLHttpRequest.b (loadfirst.js?36520:1)
CLIENT BEFORE



var emailCtrl = Runner.getControl(pageid,'client_Email');

params['email'] = emailCtrl.getValue();

params['filename'] = "PhotographyAgreement.pdf";
ajax.addPDF('pdf',{});

return false;


SERVER



$path = $button->saveTempFile( $params["pdf"] );

$result["emailaddy"] = $params["email"];

$mail = array();

$mail["to"] = $params["email"];

$mail["subject"] = "PHPRunner PDF and Email demo";

$mail["body"] = "Check the results";

$attachment = array(

"path" => $path,

"name" => $params["filename"]

);

$mail["attachments"] = array( $attachment );



$ret = runner_mail( $mail );



if( $ret["mailed"] )

{

$result["success"] = true;

}

else

{

$result["message"] = $ret["message"];

$result["success"] = false;

}


CLIENT AFTER


if( result.success ) {

$("#saveButton1").click();

ctrl.setMessage("sent ok");
} else {

ctrl.setMessage("error sending " + result.message );

}
S
Steve Seymour 3/10/2021



Hey Everyone,

I'm having an issue with the code below not executing when on an Edit page. The purpose of the button code is to create a pdf of the document they are on and send it to the email in the system. I have also tested doing just a Runner.PDF.download option and I get the same error. Any assistance/guidance would be greatly appreaciated.
ERROR:

Uncaught TypeError: Cannot read property 'replace' of undefined

at Object.Runner.displayGenericAjaxError (RunnerAll.js?36520:204)

at Object.success (RunnerAll.js?36520:2925)

at j (loadfirst.js?36520:1)

at Object.fireWith [as resolveWith] (loadfirst.js?36520:1)

at x (loadfirst.js?36520:1)

at XMLHttpRequest.b (loadfirst.js?36520:1)
CLIENT BEFORE



var emailCtrl = Runner.getControl(pageid,'client_Email');

params['email'] = emailCtrl.getValue();

params['filename'] = "PhotographyAgreement.pdf";
ajax.addPDF('pdf',{});

return false;


SERVER



$path = $button->saveTempFile( $params["pdf"] );

$result["emailaddy"] = $params["email"];

$mail = array();

$mail["to"] = $params["email"];

$mail["subject"] = "PHPRunner PDF and Email demo";

$mail["body"] = "Check the results";

$attachment = array(

"path" => $path,

"name" => $params["filename"]

);

$mail["attachments"] = array( $attachment );
$ret = runner_mail( $mail );
if( $ret["mailed"] )

{

$result["success"] = true;

}

else

{

$result["message"] = $ret["message"];

$result["success"] = false;

}


CLIENT AFTER


if( result.success ) {

$("#saveButton1").click();

ctrl.setMessage("sent ok");
} else {

ctrl.setMessage("error sending " + result.message );

}



I don't follow all the code, but I can see that your pdf is passed as params['filename'] and then you look at $params["pdf"] in your server code ?

R
RBrogen author 3/10/2021

Thanks for the reply halcyondaze. I also just tried it with only the Before Client code (server and client after code blank) with the code below to see if it would let me just download the file and I got the same error.


tempFileName = 'PhotographyAgreement.pdf';
Runner.PDF.download({}, tempFileName, pageObj);
return false;
S
Steve Seymour 3/10/2021



Thanks for the reply halcyondaze. I also just tried it with only the Before Client code (server and client after code blank) with the code below to see if it would let me just download the file and I got the same error.


tempFileName = 'PhotographyAgreement.pdf';
Runner.PDF.download({}, tempFileName, pageObj);
return false;



I just tried the code above - version 10.5 (build 36520) and all worked ok, so I'm guessing the error is in some other code on that page ?

R
RBrogen author 3/10/2021

Thanks halcyondaze ... I'm going to start digging through what could be causing the error. I appreciate you taking time from your day to respond to me. I'll post what I find shortly. Have a great day!



I just tried the code above - version 10.5 (build 36520) and all worked ok, so I'm guessing the error is in some other code on that page ?

R
RBrogen author 3/10/2021

It's weird .... I put the same button the View page (which has the same layout) and it works. The only difference between the view and edit pages is some of the code in the Edit page events. I am not getting any errors on the Edit page except when I try to run that pdf function.



Thanks halcyondaze ... I'm going to start digging through what could be causing the error. I appreciate you taking time from your day to respond to me. I'll post what I find shortly. Have a great day!

S
Steve Seymour 3/11/2021

[quote name='RBrogen' date='10 March 2021 - 10:15 PM' timestamp='1615414516' post='94065']

It's weird .... I put the same button the View page (which has the same layout) and it works. The only difference between the view and edit pages is some of the code in the Edit page events. I am not getting any errors on the Edit page except when I try to run that pdf function.
Then I guess it as to be a clash of variables/ function names / script order - the mysteries of javascript <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=94070&image=1&table=forumreplies' class='bbc_emoticon' alt=';)' />