Send Notification with PDF attachment

greenuser
Giga Contributor

Hi,

As per my requirement I want to send a notification with PDF attachment. That PDF will contain details of 'Demand' form, Its not an external file.

There is UI Action button on form, once clicked it should trigger a notification to client with current form details in PDF attachment.

Any suggestions how to achieve this.

Thanks in Advance

Regards

Arun Kumar

12 REPLIES 12

prashantnagaral
Kilo Guru

Hi Arun,



I suggest you to create a registry and generate an event when clicked on UI Action this will help you to configure the email notification along with "Include attachments". Please refer the below links where you to generate the form to PDF before sending email.



I am a creator — PDF Document Generator - Walter Brame


ServiceNow Share


ServiceNow Share


Sending Documents in an Email Notification


Export to PDF UI Action



Mark this as answered, helpful if above information help you to resolve your query



Regards


Prashant


nayanawadhiya1
Kilo Sage

Hey Arun,



I suggest you to create a registry and generate an event when clicked on UI Action this will help you to configure the email notification along with "Include attachments".


And write this code on UI Action -



var rm = new sn_ws.RESTMessageV2();


rm.setHttpMethod('GET');


var url = gs.getProperty("glide.servlet.uri") + current.getTableName()+ '.do?PDF&sys_id=' + current.sys_id;


rm.setEndpoint(url);


rm.setBasicAuth(gs.getProperty('glide.user.userid'), gs.getProperty('glide.user.password'));


rm.saveResponseBodyAsAttachment(current.getTableName(),current.sys_id,current.number+".pdf");


var response = rm.execute();



That code will convert form into PDF and attached to the attachments.


NOTE -


USERID and PASSWORD will be of ADMIN.


Hi Nayan,



Thanks for reply.


But when I'm trying to implement suggested logic "sn_ws is not defined" error is triggering. Below are my codes which I'm trying to execute using "UI Action" and Screen shot.



function dmCIO_signOff(){


  try{


  var rm = new sn_ws.RESTMessageV2();


  rm.setHttpMethod('GET');


  var url = gs.getProperty("glide.servlet.uri") + current.getTableName()+ '.do?PDF&sys_id=' + current.sys_id;


  rm.setEndpoint(url);


  rm.setBasicAuth(gs.getProperty('glide.user.userid'), gs.getProperty('glide.user.password'));


  rm.saveResponseBodyAsAttachment(current.getTableName(),current.sys_id,current.number+".pdf");


  var response = rm.execute();



  gsftSubmit(null, g_form.getFormElement(), 'dm_cio');


  }


  catch(e){


  alert('Degital WO UI Action : '+e);


  }


}


if (typeof window == 'undefined')


  closeDMTask_cio();


function closeDMTask_cio()


{


  current.state = 3;


  current.update();


  action.setRedirectURL('./u_demand_request.do?sys_id='+current.u_parent_demand);


}



find_real_file.png



Please suggest how to handle 'sn_ws is not defined' error.



Thanks in Advance


Regards
Arun Kumar


Check



Scripted REST API Plugin is active or not?