Description: Sample Groovy Script to provide default values to System Attributes when creating or editing a Placeholder.
Context: Document
Document Type: Placeholder
Remark: Accessible in On-load task mode only.
Script:
def execute(){
JsonArray attributeDetailsList = new JsonArray();
DocumentVO document = placeholderService.getPlaceholderDetails();
String revDefaultValue = "-";
attributeDetailsList.add(getAttributeJSON(IDocumentAttribute.REV, IDocumentAttribute.STANDARD, IDocumentAttribute.READ_ONLY, revDefaultValue));
attributeDetailsList.add(getAttributeJSON(IDocumentAttribute.POI, IDocumentAttribute.STANDARD, IDocumentAttribute.READ_ONLY, ""));
document.setResponseStatus(false);
document.setDynamicObject(attributeDetailsList.toString());
return document;
}
// This method will prepare and return JSON object
private JsonObject getAttributeJSON(String attributeName, boolean isCustomAttribute, boolean editOption, String defaultValue) {
JsonObject attribute = new JsonObject();
attribute.addProperty("attributeName", attributeName);
attribute.addProperty("isEditable", editOption);
attribute.addProperty("isCustomAttribute", isCustomAttribute);
attribute.addProperty("defaultValue", defaultValue);
return attribute;
}