If there are more than one published form with different versions, the template picked for record generation is not always the latest form. The issue is with below code.
MetadataService
def getOutputDataModel(templateName) {
List forms = ActivityForm.where {
status != Status.DELETED
publicationStatus == PublicationStatus.PUBLISHED
sections { templateName == templateName}
}.list()
ActivityForm form = forms.max{it.version}
.......
}
If there are more than one published form with different versions, the template picked for record generation is not always the latest form. The issue is with below code.