diff --git a/entity/Order_entity/entityfields/contact_id/onValueChange.js b/entity/Order_entity/entityfields/contact_id/onValueChange.js index f9eb528b6dc9d3dbd8d3a99ccaee424ebba0d4d7..0b2d7b214335f77e643562f133f99f562c2e8fba 100644 --- a/entity/Order_entity/entityfields/contact_id/onValueChange.js +++ b/entity/Order_entity/entityfields/contact_id/onValueChange.js @@ -47,12 +47,16 @@ if(contactId != "") //Salesproject Preset var today = datetime.today(); - var salesProjectId = newSelect("SALESPROJECT.SALESPROJECTID") + var salesProjectIds = newSelect("SALESPROJECT.SALESPROJECTID") .from("SALESPROJECT") .where("SALESPROJECT.CONTACT_ID", contactId) - .cell(); - if(salesProjectId) + .arrayColumn(); + if(salesProjectIds.length === 1) { - neon.setFieldValue("$field.OBJECT_ROWID", salesProjectId); + neon.setFieldValue("$field.OBJECT_ROWID", salesProjectIds[0]); + } + else + { + neon.setFieldValue("$field.OBJECT_ROWID", ""); } } \ No newline at end of file diff --git a/entity/Order_entity/entityfields/object_rowid/displayValueProcess.js b/entity/Order_entity/entityfields/object_rowid/displayValueProcess.js index 097818829c387fa6035aac140d75f2f5f9110dc1..0d55b20141440538ce23bfa4ca57f61d87f3da69 100644 --- a/entity/Order_entity/entityfields/object_rowid/displayValueProcess.js +++ b/entity/Order_entity/entityfields/object_rowid/displayValueProcess.js @@ -4,11 +4,11 @@ import("system.db"); import("system.result"); import("Context_lib"); -if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && !vars.get("$field.OBJECT_ROWID")) +var res = ""; + +if (vars.exists("$field.OBJECT_TYPE") && vars.get("$field.OBJECT_TYPE")) { - result.string(""); + res = ContextUtils.getTitleByContext(vars.get("$field.OBJECT_TYPE"), vars.get("$field.OBJECT_ROWID")); } -else if (vars.exists("$field.OBJECT_TYPE") && vars.get("$field.OBJECT_TYPE")) -{ - result.string(ContextUtils.getTitleByContext(vars.get("$field.OBJECT_TYPE"), vars.get("$field.OBJECT_ROWID"))); -} \ No newline at end of file + +result.string(res); \ No newline at end of file