Skip to main content

Groovy Script - Enable the 'Include QR code' option in the Download Preference

Description: Sample Groovy Script to enable the Include QR code option in the download preferences. It can apply to both Static and Dynamic QR code types.

Click here to learn more.

Context: Document

Document Type: File

Remark: Accessible in 'On Load' task mode only.

Script:

def execute(){
boolean checked = true;
boolean unchecked = false;
DocumentVO document = documentService.getDocumentDetails();

JsonArray optionList = new JsonArray();

JsonObject qrCodeOption = new JsonObject();
qrCodeOption.addProperty(IGroovyConstant.VISIBLE, true);
qrCodeOption.addProperty(IGroovyConstant.EDITABLE, true);
qrCodeOption.addProperty(IGroovyConstant.DEFAULT_VALUE, checked);
qrCodeOption.addProperty(IGroovyConstant.OPTION_NAME, IGroovyConstant.EMBED_QR_CODE_OPTION);

optionList.add(qrCodeOption);

/*
JsonObject fileRenameOption = new JsonObject();
fileRenameOption.addProperty(IGroovyConstant.VISIBLE, true);
fileRenameOption.addProperty(IGroovyConstant.EDITABLE, true);
fileRenameOption.addProperty(IGroovyConstant.DEFAULT_VALUE, unchecked);
fileRenameOption.addProperty(IGroovyConstant.OPTION_NAME, IGroovyConstant.RENAME_FILE_OPTION);

optionList.add(fileRenameOption);
*/

document.setResponseStatus(false);
document.setDynamicObject(optionList.toString());
return document;
}
Did this answer your question?