Skip to content
Snippets Groups Projects
Commit 9d165c07 authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

fix document template - onvalidation if type is undefined

parent de655650
No related branches found
No related tags found
No related merge requests found
import("system.vars");
// needed to correctly save the file
vars.set("$context.changedContentByUser", true);
\ No newline at end of file
vars.set("$context.changedContentByUser", true);
import("system.neon");
import("system.translate");
import("system.result");
import("system.logging");
import("system.vars");
import("Bulkmail_lib");
import("DocumentTemplate_lib");
......@@ -12,27 +11,36 @@ if (vars.exists("$context.currentTemplateType") && (vars.get("$sys.recordstate")
var kind = vars.get("$field.KIND");
var classification = vars.get("$field.CLASSIFICATION");
var type = vars.get("$context.currentTemplateType");
// Bulkmail
if (kind == $KeywordRegistry.documentTemplateType$mail() && classification == $KeywordRegistry.documentTemplateTypeCategory$serial()
&& !BulkMailUtils.isValidTemplateType(type)
// Single mail
|| kind == $KeywordRegistry.documentTemplateType$mail() && classification == $KeywordRegistry.documentTemplateTypeCategory$single()
&& type != DocumentTemplate.types.EML && type != DocumentTemplate.types.HTML && type != DocumentTemplate.types.PLAIN && type != DocumentTemplate.types.TXT
// Single letter
|| kind == $KeywordRegistry.documentTemplateType$letter() && classification == $KeywordRegistry.documentTemplateTypeCategory$single()
&& type != DocumentTemplate.types.DOCX && type != DocumentTemplate.types.ODT && type != DocumentTemplate.types.PLAIN && type != DocumentTemplate.types.TXT
// Bulkletter
|| kind == $KeywordRegistry.documentTemplateType$letter() && classification == $KeywordRegistry.documentTemplateTypeCategory$serial()
&& type != DocumentTemplate.types.ODT
// Modular HTML template
|| kind == $KeywordRegistry.documentTemplateType$textModular() && classification == $KeywordRegistry.documentTemplateTypeCategory$htmlTemplate()
&& type != DocumentTemplate.types.HTML
// Modular - all except HTML template
|| kind == $KeywordRegistry.documentTemplateType$textModular() && classification != $KeywordRegistry.documentTemplateTypeCategory$htmlTemplate()
&& type != DocumentTemplate.types.PLAIN && type != DocumentTemplate.types.TXT
)
var type;
if (vars.exists("$context.currentTemplateType"))
type = vars.get("$context.currentTemplateType");
if (type == "undefined")
type = undefined;
if (type != undefined)
{
result.string(translate.text("Wrong filetype for the current document template type and classification."))
// Bulkmail
if (kind == $KeywordRegistry.documentTemplateType$mail() && classification == $KeywordRegistry.documentTemplateTypeCategory$serial()
&& !BulkMailUtils.isValidTemplateType(type)
// Single mail
|| kind == $KeywordRegistry.documentTemplateType$mail() && classification == $KeywordRegistry.documentTemplateTypeCategory$single()
&& type != DocumentTemplate.types.EML && type != DocumentTemplate.types.HTML && type != DocumentTemplate.types.PLAIN && type != DocumentTemplate.types.TXT
// Single letter
|| kind == $KeywordRegistry.documentTemplateType$letter() && classification == $KeywordRegistry.documentTemplateTypeCategory$single()
&& type != DocumentTemplate.types.DOCX && type != DocumentTemplate.types.ODT && type != DocumentTemplate.types.PLAIN && type != DocumentTemplate.types.TXT
// Bulkletter
|| kind == $KeywordRegistry.documentTemplateType$letter() && classification == $KeywordRegistry.documentTemplateTypeCategory$serial()
&& type != DocumentTemplate.types.ODT
// Modular HTML template
|| kind == $KeywordRegistry.documentTemplateType$textModular() && classification == $KeywordRegistry.documentTemplateTypeCategory$htmlTemplate()
&& type != DocumentTemplate.types.HTML
// Modular - all except HTML template
|| kind == $KeywordRegistry.documentTemplateType$textModular() && classification != $KeywordRegistry.documentTemplateTypeCategory$htmlTemplate()
&& type != DocumentTemplate.types.PLAIN && type != DocumentTemplate.types.TXT
)
{
result.string(translate.text("Wrong filetype for the current document template type and classification."))
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment