Scripting; Send print view of workspace via email.

Scripting; Send print view of workspace via email.

Anonymous
Not applicable
871 Views
5 Replies
Message 1 of 6

Scripting; Send print view of workspace via email.

Anonymous
Not applicable

Let's start with, I'm new to scripting........

 

I'm trying to send print view (of details tab) via e-mail;

 

My Script;

var email = new Email();

 

email.to = '[email protected]';
email.subject = 'Deviation Has Been Approved';
email.body = getPrintView('RecInsp');
email.send();

 

Print view has been created (see image);

print_view.JPG

 

 

 

 

When testing the script I get the following error;

There is an error in the script on line 5, column 0. Wrapped java.lang.NullPointerException (PC_dev_req_nofification_insp#5)

error.JPG

 

Any help would be greatly appreciated!

 

 

0 Likes
872 Views
5 Replies
Replies (5)
Message 2 of 6

michelle.stone
Autodesk
Autodesk

Quick question - did you set it up as a Basic Print View or Advanced Print View?  I did a quick test with your code (just changed email to mine so I didn't spam you!!) and it works when the print view is set up as an Advanced one.  I ran it as an On Demand script for quick testing.

 

APV:

apv.pngscript.pngresult.png



Michelle Stone
Technical Marketing, PDM & PLM
Autodesk, Inc.
0 Likes
Message 3 of 6

tony.mandatori
Autodesk
Autodesk

There was a bug with getPrintView where the generation of the printview would trigger a validation script.

 

To avoid it, i used to copy the text in the printview into a string variable and then use that for the body of the email.

 

0 Likes
Message 4 of 6

Anonymous
Not applicable

Hi Michelle,

 

Thanks for the quick response. Turns out I did not have an advanced print view set up. Added one (RecInsp) but still getting the same error.

0 Likes
Message 5 of 6

Anonymous
Not applicable

Hi Tony,

 

Gave that a try, same end result, "There is an error in the script on line 2, column 0. Wrapped java.lang.NullPointerException (RECINSP_DEV#2)"

 

Script error.JPG

 

Here is my script

 

var email = new Email();
var emailbody = getPrintView('RecInsp');

 

email.to = '[email protected]';
email.subject = 'Deviation Has Been Approved';
email.body = emailbody;
email.send();

0 Likes
Message 6 of 6

tony.mandatori
Autodesk
Autodesk

Avoid calling getPrintView altogether... because it tries to run unnecessary validation.

 

Copy the report source code (by clicking the gear icon in the report setup) into the script instead.

 

Does that help?

0 Likes