How to generate a pdf from a form and send it to another table

suprakash
Giga Expert

Suppose I am entering some data in a form of table u_candidate_details   and when i submit or save the form a record will be inserted in table u_candidate_database and a pdf attachment will be added on the record that was created on table u_candidate_database . the attachment will be pdf of the form view u_candidate_details  

1 ACCEPTED SOLUTION

nayanawadhiya1
Kilo Sage

Hey Suprakash,



Write a INSERT BUSINESS RULE -



var gr = new GlideRecord ('u_candidate_database');


gr.addQuery(Filter_condition);


gr.query();


if(gr.next())


{


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(gr.getTableName(),gr.sys_id,current.number+".pdf");
      var response = rm.execute();

}


View solution in original post

41 REPLIES 41

It will include attachments in email.


find_real_file.png


I pasted the same code in BR for Incident table, i am getting an email but pdf is getting attached.



Do i need to active any plugins ?



find_real_file.png



BR.png


Hey Abdul,



Replace you BR with these -


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();



Note -


Create that property on sys_properties table and userid should be of ADMIN.


I did create that 2 properties earlier it self and USER id is Admin. Changed the code as per your earlier mesage but still pdf is not getting converted and attached in email.



find_real_file.png


Show me your BR "When to Run" Condition as well as script.