diff --git a/entity/Offer_entity/Offer_entity.aod b/entity/Offer_entity/Offer_entity.aod index 602e5cd157e6689e0c78482006527734981a8e8b..6b7804ef7ee2515449b6f056abbdc8f507bc136c 100644 --- a/entity/Offer_entity/Offer_entity.aod +++ b/entity/Offer_entity/Offer_entity.aod @@ -60,6 +60,7 @@ <title>Probability</title> <consumer>KeywordProbabilities</consumer> <contentType>NUMBER</contentType> + <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/probability/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/Offer_entity/entityfields/probability/displayValueProcess.js</displayValueProcess> </entityField> <entityField> diff --git a/entity/Offer_entity/entityfields/deliveryterms/valueProcess.js b/entity/Offer_entity/entityfields/deliveryterms/valueProcess.js index 4463e8d84dc0de8bd1c3fb297d48119201e7a764..9d4288fee2165c91476d90ec0f0d636bde33d4a6 100644 --- a/entity/Offer_entity/entityfields/deliveryterms/valueProcess.js +++ b/entity/Offer_entity/entityfields/deliveryterms/valueProcess.js @@ -1,3 +1,5 @@ +import("Keyword_lib"); +import("KeywordRegistry_basic"); import("AttributeRegistry_basic"); import("system.neon"); import("system.result"); @@ -11,13 +13,19 @@ if (vars.exists("$param.OfferDeliveryTerm_param") && vars.get("$param.OfferDeliv } else if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) { + var presetValue = ""; var contactIds = ContactUtils.getPersOrgIds(vars.getString("$field.CONTACT_ID")) if (contactIds.length >= 3 && contactIds[2]) { var orgContactId = ContactUtils.getOrgContactId(contactIds[2]); if (orgContactId) { - result.string(AttributeRelationUtils.getAttribute($AttributeRegistry.deliveryTerm(), orgContactId)); + presetValue = AttributeRelationUtils.getAttribute($AttributeRegistry.deliveryTerm(), orgContactId); } } + + if (presetValue) + result.string(presetValue); + else + result.string(KeywordUtils.getFirst($KeywordRegistry.deliveryTerm())); } \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/paymentterms/valueProcess.js b/entity/Offer_entity/entityfields/paymentterms/valueProcess.js index 020e52b587cd8ab247a95db399a99b50e9755925..98081578fa2e983e3da8bcc77d81645252d65a20 100644 --- a/entity/Offer_entity/entityfields/paymentterms/valueProcess.js +++ b/entity/Offer_entity/entityfields/paymentterms/valueProcess.js @@ -1,5 +1,7 @@ +import("Keyword_lib"); import("Contact_lib"); import("AttributeRegistry_basic"); +import("KeywordRegistry_basic"); import("system.neon"); import("system.result"); import("system.vars"); @@ -11,13 +13,19 @@ if (vars.exists("$param.OfferPaymentTerm_param") && vars.get("$param.OfferPaymen } else if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) { + var presetValue = ""; var contactIds = ContactUtils.getPersOrgIds(vars.getString("$field.CONTACT_ID")) if (contactIds.length >= 3 && contactIds[2]) { var orgContactId = ContactUtils.getOrgContactId(contactIds[2]); if (orgContactId) { - result.string(AttributeRelationUtils.getAttribute($AttributeRegistry.paymentTerm(), orgContactId)); + presetValue = AttributeRelationUtils.getAttribute($AttributeRegistry.paymentTerm(), orgContactId); } } + + if (presetValue) + result.string(presetValue); + else + result.string(KeywordUtils.getFirst($KeywordRegistry.paymentTerm())); } \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/probability/valueProcess.js b/entity/Offer_entity/entityfields/probability/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..410c669a772468381243551aa7d9577c25f4d07c --- /dev/null +++ b/entity/Offer_entity/entityfields/probability/valueProcess.js @@ -0,0 +1,13 @@ +import("Keyword_lib"); +import("KeywordRegistry_basic"); +import("AttributeRegistry_basic"); +import("system.neon"); +import("system.result"); +import("system.vars"); +import("Attribute_lib"); +import("Contact_lib"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) +{ + result.string(KeywordUtils.getFirst($KeywordRegistry.offerProbability())); +} \ No newline at end of file diff --git a/process/Keyword_lib/process.js b/process/Keyword_lib/process.js index 62e96d19e0b903d9c5150fcc6e3bbe8a068ca751..e40c7c2f077d16d91f3b211d89d9714087e72410 100644 --- a/process/Keyword_lib/process.js +++ b/process/Keyword_lib/process.js @@ -173,6 +173,21 @@ KeywordUtils.exists = function(pKeyId, pContainerName) return parseInt(db.cell(sql)) > 0; }; +/** + * Get the first keyword Keyid from a container + * + * @param {String} pContainerName name of the keyword container that shall be resolved + * @param {String} [pLocale=current client language] specifies the locale for translating the title; can be false if nothing shalle be translated + * + * @return {String} the keyid or "" + */ +KeywordUtils.getFirst = function(pContainerName, pLocale) +{ + var keywordData = KeywordData.getSimpleData(pContainerName, pLocale); + + return (keywordData && keywordData.length > 0 ? keywordData[0][0] : ""); +}; + /** * get the translated container name. *