Update the Repeating Field Values and Return Updated XML
Description: Sample Groovy script to update the repeating fields values and return updated XML.
Context: Form
Context: Form
Script:
def execute() {
FormVO formVO = formService.getFormDetails(true);
String formId = String.valueOf(formVO.getFormID());
Map<String, Map<String, String>> resultMap = new HashMap<String, Map<String, String>>();
//below guid is generated dynamically in repeating field
String guid = "XXXXXXXX";
Map<String, String> innerMap = new HashMap<String, String>();
innerMap.put("SAPLineNum", "0");
innerMap.put("SAPItemCode", "51");
resultMap.put(guid, innerMap);
String updatedXML = formService.updateXmlValuesByRepeatingNode(formVO.getXmlData(), "XXXXXXXX", "XXXXXXXX", resultMap);
// updatedXML is xml with new values.
Map<String, Object> createFormMap = new HashMap<> ();
createFormMap.put(ISystemConstantsDM.FORM_ID, formId);
createFormMap.put(ISystemConstantsDM.IS_DIST_FOR_IDS, "false");
createFormMap.put(ISystemConstantsDM.ASSOCIATE_CURRENT_FORM_ASSOCIATED_FILES, "false");
createFormMap.put(ISystemConstantsDM.ASSOCIATE_CURRENT_FORM_ASSOCIATED_FORMS, "false");
createFormMap.put(ISystemConstantsDM.COPY_CURRENT_FORM_ATTACHMENTS, "false");
createFormMap.put(ISystemConstantsDM.ASSOCIATE_CURRENT_FORM_TO_NEW_FORM, "false");
createFormMap.put(ISystemConstantsDM.XML_DATA, updatedXML);
formService.editForm(createFormMap);
}
