Skip to content
Snippets Groups Projects
valueProcess.js 869 B
import("system.neon");
import("Sql_lib");
import("system.result");
import("system.vars");
import("system.db");
import("Document_lib");

if (vars.get("$sys.recordstate") && vars.get("$sys.recordstate") != neon.OPERATINGSTATE_NEW)
{
    var binMetadatas = db.getBinaryMetadata("LEADIMPORT", "IMPORTFILE", vars.get("$field.LEADIMPORTID"), false, SqlUtils.getBinariesAlias(), "");

    if (binMetadatas.length > 0)
    {
        // preset with data from db. This is mostly to allow just editing the other fields without uploading a file (because this field is mandatory)
        var resultValue = binMetadatas[0].filename;
        resultValue += ";" + db.getBinaryContent(binMetadatas[0].id, SqlUtils.getBinariesAlias());
        resultValue += ";" + binMetadatas[0].mimetype;

        result.string(resultValue);
    } else {
        result.string("FILE MISSING");
    }
}