To run/create a printable in Creatio via client-side Javascript on a page, there’s an easy to use web service. We can also use the ServiceHelper module to make it easy to create the printable document as well.
To run a printable and download the doc via code, first add the ServiceHelper module to the modules list at the top of the page. Additionally, if we want to show the “loading” animation while the printable is being created, we can also add the MaskHelper module as well.
define("UsrMyCustom1Page", ["ServiceHelper", "MaskHelper"], function(ServiceHelper, MaskHelper) {
With the modules added to the top of the page, the code to create the printable document would look as follows:
// Notę, the reportId below is the Id of the printable.
// You can get this from the end of the URL when edit the printable in the report setup screen
var reportId = "7f5de1ad-fb4b-2ad6-b6fc-4f05f30a7f0f";
// we'll pass the below to the service. The recordsIds is the record (or records) the printable will be run for
var serviceData = {
"templateId": reportId,
"recordIds": [ this.get("Id") ]
};
// show loading indicator
MaskHelper.ShowBodyMask();
// call the service
ServiceHelper.callService("ReportService", "CreateReportsList", function(response) {
MaskHelper.HideBodyMask();
// now download the file
var elem = document.createElement("a");
elem.href = "../rest/ReportService/GetReportFile/" + CreateReportsListResult[0];
elem.download = "ReportName";
if (Ext.isIE) {
elem.target = "_blank";
}
document.body.appendChild(elem);
elem.click();
document.body.removeChild(elem);
}, serviceData, this);
The result is that when the code above executes, the printable will be created and downloaded. The user will simply see a quick loading animation and then a file will download.




Hi, Ryan, Is it possible to do same func in FreedomUI page?
Yes. Technically, you could use the ServiceHelper module as the code in this article, but it would be better to transition to the sdk methods for calling the service. See https://customerfx.com/article/calling-configuration-web-services-from-client-side-code-in-a-creatio-freedom-ui-page/
Something like this (not tested):
const recordId = await request.$context.Id; var payload = { "templateId": reportId, "recordIds": [recordId] }; const httpService = new sdk.HttpClientService(); const response = await httpService.post("rest/ReportService/CreateReportsList", payload); const fileUrl = "../rest/ReportService/GetReportFile/" + response.body.CreateReportsListResult[0]; // do download of fileUrlRyan