Description: Sample Groovy script to read data from custom XML parts of a .dwg file and set attributes in the File Upload screen.
Context: Document (.dwg)
Document Type: File
Remark: Accessible in 'On-Load' task mode only.
Script:
def execute(){
JsonArray attributeDetailsList = new JsonArray();
DocumentVO document = documentService.getDocumentDetails();
attributeDetailsList.add(getAttributeJSON(IDocumentAttribute.REV, IDocumentAttribute.STANDARD, IDocumentAttribute.READ_ONLY,"Revision")); // Params: Attribute Name, Type Of Atribute, Editable/Read Only
attributeDetailsList.add(getAttributeJSON("Signatory Department", IDocumentAttribute.CUSTOM, IDocumentAttribute.READ_ONLY,"AuthorDepartment"));
attributeDetailsList.add(getAttributeJSON("My Classification", IDocumentAttribute.CUSTOM, IDocumentAttribute.READ_ONLY,"Classification"));
document.setResponseStatus(false);
document.setDynamicObject(attributeDetailsList.toString());
return document;
}
// This is a generic method to prepare JSON object. No need to do any change in this method.
private JsonObject getAttributeJSON(String attributeName, boolean isCustomAttribute, boolean editOption, String propertyName) {
JsonObject attribute = new JsonObject();
attribute.addProperty("attributeName", attributeName);
attribute.addProperty("isEditable", editOption);
attribute.addProperty("isCustomAttribute", isCustomAttribute);
attribute.addProperty("filePropertyName", propertyName);
attribute.addProperty("ruleApplyToFileFormat", "dwg");
attribute.addProperty("readAttributeValueFromFileContent", "true");
return attribute;
}