Description: Sample Groovy script to update placeholder attributes, including both basic system attributes and custom attributes. The script demonstrates how to fetch placeholder details with configurable options, modify values, and apply updates using the placeholder service.
Context: Document
Document Type: Placeholder
Remark: Accessible in Post task mode only.
Script:
def execute(){
HashMap<Object, Object> optionMap = new HashMap();
optionMap.put(RevisionDetailsOption.BASIC_DETAILS, true);
optionMap.put(RevisionDetailsOption.CUSTOM_ATTRIBUTES, true);
optionMap.put(RevisionDetailsOption.APPLY_TIMEZONE, IGroovyConstant.PUBLISHER);
DocumentVO documentVO = placeholderService.getPlaceholderDetails(optionMap);
// Update Basic Attributes
documentVO.setDocRef(documentVO.getDocRef() + "_1");
documentVO.setRevision(documentVO.getRevision() + "_1");
documentVO.setDocTitle(documentVO.getDocTitle() + "_1");
documentVO.setPurposeOfIssue("---"); //Make sure you provide exact name of POI. It is case sensitive.
documentVO.setPrivate(false);
documentVO.setRevisionNotes(documentVO.getRevisionNotes() + "_1");
// Update Custom Attributes. Make sure you provide exact oroginal name of custom attribute, not language specific. It is case sensitive.
Map<String, List<String>> customAttributeMap = new HashMap<String, List<String>>();
// DROPDOWN
List<String> dropDownValue = new ArrayList<String>();
dropDownValue.add("ABC1"); // make sure you provide proper value here which is exist in this custom attribute
customAttributeMap.put("Placeholder Dropdown", dropDownValue);
// MULTI CHECKBOX
List<String> multiCheckboxValues = new ArrayList<String>();
multiCheckboxValues.add("M1"); // make sure you provide proper value here which is exist in this custom attribute
multiCheckboxValues.add("M2");
customAttributeMap.put("Placeholder MultipleSelection", multiCheckboxValues);
//RADIO BUTTON
List<String> radioButtonValues = new ArrayList<String>();
radioButtonValues.add("Yes");
customAttributeMap.put("Placeholder Radio", radioButtonValues);
//TEXT BOX
List<String> textBoxValue = new ArrayList<String>();
textBoxValue.add("777");
customAttributeMap.put("Placeholder textbox", textBoxValue);
//COORDINATES
List<String> coordinatesValues = new ArrayList<String>();
coordinatesValues.add("444");
coordinatesValues.add("555");
coordinatesValues.add("666");
customAttributeMap.put("Placeholder coordinates", coordinatesValues); // make sure you add values for all the coordinates defined in custom attributes 1/2/3.
//MAP
List<String> mapValue = new ArrayList<String>();
mapValue.add("55.68970825,-1.91009712"); // This should be based on Type of Map
customAttributeMap.put("Placeholder map", mapValue);
documentVO.setCustomAttribute(customAttributeMap);
ArrayList<DocumentVO> documents = new ArrayList<DocumentVO>();
documents.add(documentVO);
HashMap<Object, Object> optionDataMap = new HashMap();
optionDataMap.put(RevisionDetailsOption.APPLY_TIMEZONE, IGroovyConstant.PUBLISHER);
// Assign attributes to documents
placeholderService.updatePlaceholders(documents,optionDataMap);
}