Question

Running a printable from code

Is it possible to run a printable from javascript code or custom added button? 

I have a customer with several hundred merge forms they want to add to their Bpm'online system. The current print menus would be difficult to use with hundreds of printable merge forms listed, so I am looking at other possible ways to handle this. Open to any other suggestions. 

Like

2 comments

Dear Ryan,

You can explore, how printable is called in a Network section in a browser console. For example, that's why Account printable "Company summary" looks in a console:

In the example below you will find how you can do a similar task from c# in a script task. For example, the following code generates a printable and saves it in activity files:
var reportService =new Terrasoft.Configuration.ReportService.ReportService();

Terrasoft.Configuration.ReportService.ReportData report = reportService.GenerateMSWordReport(PrintableId.ToString()), ObjectId.ToString(), ConvertToPdf);

var entity = UserConnection.EntitySchemaManager.GetInstanceByName("ActivityFile");

var fileEntity = entity.CreateEntity(UserConnection);

fileEntity.SetDefColumnValues();

fileEntity.SetColumnValue("ActivityId", AddActivityUserTask.RecordId);

fileEntity.SetColumnValue("TypeId", AttachmentType);

fileEntity.SetColumnValue("Name","ExamplePrintable.docx");

fileEntity.SetColumnValue("Data", report.Data);

fileEntity.Save();

return true;

 

Peter,

This was very helpful. Thank you!

Log in or register to comment