Fx.template: Print related functions Print template related services, because this interface will be time-consuming, use restProxy to process it separately, and separate the time-consuming from proxyAPI
1. Print a file using a template
Fx.template.print(<String objectAPIName>, <String id>, <String templateId>, <String instanceId>, <String orientation>)
Parameter Description
| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| objectAPIName | String | The object API name of the print data |
| id | String | id of the print data |
| templateId | String | print template id |
| instanceId | String | Optional parameter, used together with orientation, approval instance id (just pass null when printing object data) |
| orientation | String | optional parameter, used together with instanceId, Landscape: horizontal, Portrait: vertical |
return type
APIResult
Return value description
fileType file type path file path fileSize file size
Java example
String objectAPIName = "object_rqa45__c";
String objectId = "600817eb048fdb000179d37d";
String templateId = "5fe9cbe2e66fd10001a2a339";
String orientation = "Portrait";
APIResult ret = Fx.template.print(objectAPIName, objectId, templateId, null, orientation);
if(ret.isError()){
Fx.log.info("Print error: " + ret.message());
}else{
Fx.log.info(ret.getData());
}
Groovy example
String objectAPIName = "object_rqa45__c"
String objectId = "600817eb048fdb000179d37d"
String templateId = "5fe9cbe2e66fd10001a2a339"
String orientation = "Portrait"
def(Boolean error,Map result,String errorMessage) = Fx.template.print(objectAPIName,objectId,templateId,null,orientation)
if( error ){
Fx.log.info("Print error: " + errorMessage)
}else{
Fx.log.info(result)
}
Precautions
- The printing call will take a long time, please try to put it in the action after the process, or an asynchronous function to avoid the page execution timeout