hi, I have a suitelet which renders a pdf inline. ...
# suitescript
b
hi, I have a suitelet which renders a pdf inline. I'm trying to access that suitelet from an user event script and send an email with the suitelet pdf as an attachment, but for some reason the pdf attachment comes empty, does anyone know why ?
r
@bogdanThat seems a bit redundant, why not just have a submit button that will send out the email with the attached PDF?
Also I believe since you’re modifying the body of the PDF and changing it to BASE64 It will corrupt the information.
b
because the pdf needs to be emailed when a vendor bill is approved
nlapiCreateFile is throwing an unexpected error if I don't convert to base64
if the output is pdf
r
@bogdan what does PDF email have it hits the first line
b
@rmlakhani the pdf.getBody() starts like this "%PDF-1.3\n%����\n1 0 obj\n<</Type/Catalog/Pages 2 0 R/Lang(en-US)/Names 3 0 R/Metadata 4 0 R>"
this is what i get in the debugger
r
log out the value of PDF
b
%PDF-1.3 %���� 1 0 obj <</Type/Catalog/Pages 2 0 R/Lang(en-US)/Names 4 0 R/Metadata 5 0 R>> endobj 2 0 obj <</Type/Pages/Kids[6 0 R 7 0 R]/Count 2>> endobj 3 0 obj <</Producer(http://bfo.com/products/report?version=1.1.61-r25714)/CreationDate(D:20180829060038-07'00')/ModDate(D:20180829060039-07'00')>> endobj 4 0 obj <</Dests 8 0 R>> endobj 5 0 obj <</Type/Metadata/Subtype/XML/Length 875>>stream <?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?> <x:xmpmeta xmlns:x="adobensmeta/" x:xmptk="BFOXMP 1.1.61-r25714"><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about=""><pdfProducer&gt;http//bfo.com/products/report?version=1.1.61-r25714</pdfProducer&gt;&lt;/rdfDescription><rdf:Description xmlns:xmp="http://ns.adobe.com/xap/1.0/" rdf:about=""><xmpCreateDate&gt;2018 08 29T060038 0700</xmpCreateDate&gt;&lt;xmpModifyDate>2018-08-29T060039-0700&lt;/xmpModifyDate><xmpMetadataDate&gt;2018 08 29T060039 0700</xmpMetadataDate&gt;&lt;/rdfDescription><rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" rdf:about=""><dcdate&gt;&lt;rdfSeq><rdfli&gt;2018 08 29T060039 0700</rdfli&gt;&lt;/rdfSeq></dcdate&gt;&lt;dcformat>application/pdf</dcformat&gt;&lt;/rdfDescription></rdfRDF&gt;&lt;/xxmpmeta> <?xpacket end='r'?> endstream endobj 6 0 obj <</Type/Page/MediaBox[0 0 612 792]/Resources<</ColorSpace<</DefaultRGB 10 0 R>>/ProcSet[/PDF/Text/ImageC]/Font<</R1 11 0 R/R2 12 0 R>>/XObject<</R3 13 0 R>>>>/Contents[9 0 R]/Parent 2 0 R>> endobj 7 0 obj <</Type/Page/MediaBox[0 0 612 792]/Resources<</ColorSpace<</DefaultRGB 10 0 R>>/ProcSet[/PDF/Text/ImageC]/Font<</R1 11 0 R/R2 12 0 R/R4 14 0 R>>/XObject<</R3 13 0 R>>>>/Contents[15 0 R]/Parent 2 0 R>> endobj 8 0 obj <</Names[(page1)16 0 R(page2)17 0 R]>> endobj 9 0 obj <</Filter/FlateDecode/Length 1455>>stream x��W�r�6��+�锚�a��Y�k'M=�$�1N4GKbBRM�=��{AJ2)�tj�5�p��{�gE^q�4�h��fh�_|��=�7t:��4{@�]<vňʸLG�� w2ɗz�����G���D��!������#�a{7���2����U���7��!~A׮��?�$�Kt�q[.� ���61?~w��/�2)+4ݔ��_���Ɛ�]�~9�>G�0̭��NS ,!1űDJ+���� Gy�>�#`Hh"-P��bZ���O����R%%��W�ԇ/�h���S/� )&���{z�䋤(�M�E��u�@z�� U�:)�|S�N�+4ɓ6Tö�i���<[��u��8'L�+@-�U �"on�쵷�-���e k����<_W��I�Vy�����(�,��&�����fS��/�ʕU(��XH� ��� ��jo3t���<R�En��D�\y�%�HB?��ɫR+L�PͅT �D�w � {��k�m��� C�8 �P�1e�g�6зu�6:��j�4�ܧ�u!�;�y���ʭ+t�|�AA��4�J�s4uˇ�q�\� ��g�_o�g�ku��.^0����V,�FC�P��5�X,X�wg2��g� ��Rh��c��(�T�YF_���{Dn�b�1�)眵bB�N�)#�K�Bw������޳��B K|H&:..���bPɰ�u���޷�s��K�m��_t�a���j�#5Y�� �j;V[�Rj��et�y�}��u�n0D�����j�4M1,�/Gi�F���J`�K���%�|��Ч�>��m%�PUI�Y� �� ��j��T����K��+�������h���F~ �� -m;�-HW�g�a��z���U0E��"J�ݮ7j�On]�����o�*���uCl��0�f ��� '�#��(H�g�0��&g�y�H�ǹ���a8�D��F�~nݮ�й�!Mcu��]�����̠ϰh�PY�����j�'�� �R�;?�WXH'sji�d�M�*Y�I���ʚ���k�UEr�Aܨ����`΃�)L �4t�[��dP4� ,� L �ҽ�e�s���a`E�|��҅� +�Î-4�"t!i1�5�gH@�M��/�0�+ y��-\D��������B͑?,�����b��vѵ�j ���Ȃ�=t�|�ő�m�b7�(����h�. ��߯���);�
r
nlapiRequestURL is typically used to get formatted data. try removing {‘Accept’:‘application/pdf’}
r
Why not move the part that generates the PDF to the UserEvent? Why the need for a separate Suitelet?
l
Agree that it is strange and I would also move it to User Event. If you really need to call a suitelet for some strange reason and you can't get this pdf as a response you can alsways save it in file cabinet and return id from a suitelet, then load it in User Event.