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

preset offer terms with attrs from org if its a person

parent 370bbf92
No related branches found
No related tags found
No related merge requests found
import("system.logging");
import("AttributeRegistry_basic");
import("system.neon");
import("system.result");
import("system.vars");
import("Attribute_lib");
import("Contact_lib");
if (vars.exists("$param.OfferDeliveryTerm_param") && vars.get("$param.OfferDeliveryTerm_param"))
{
......@@ -10,9 +12,13 @@ if (vars.exists("$param.OfferDeliveryTerm_param") && vars.get("$param.OfferDeliv
}
else if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
{
var contactId = vars.getString("$field.CONTACT_ID");
if (contactId)
{
result.string(AttributeRelationUtils.getAttribute($AttributeRegistry.deliveryTerm(), contactId));
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));
}
}
}
\ No newline at end of file
import("system.result");
import("system.vars");
import("Contact_lib");
if (vars.get("$field.CONTACT_ID"))
{
var ids = ContactUtils.getPersOrgIds(vars.getString("$field.CONTACT_ID"));
if (ids.length >= 3 && ids[2])
result.string(ContactUtils.getPersOrgIds(vars.getString("$field.CONTACT_ID"))[2]);
import("system.result");
import("system.vars");
import("Contact_lib");
if (vars.get("$field.CONTACT_ID"))
{
var ids = ContactUtils.getPersOrgIds(vars.getString("$field.CONTACT_ID"));
if (ids.length >= 3 && ids[2])
result.string(ids[2]);
}
\ No newline at end of file
import("Contact_lib");
import("AttributeRegistry_basic");
import("system.neon");
import("system.result");
......@@ -10,9 +11,13 @@ if (vars.exists("$param.OfferPaymentTerm_param") && vars.get("$param.OfferPaymen
}
else if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
{
var contactId = vars.getString("$field.CONTACT_ID");
if (contactId)
var contactIds = ContactUtils.getPersOrgIds(vars.getString("$field.CONTACT_ID"))
if (contactIds.length >= 3 && contactIds[2])
{
result.string(AttributeRelationUtils.getAttribute($AttributeRegistry.paymentTerm(), contactId));
var orgContactId = ContactUtils.getOrgContactId(contactIds[2]);
if (orgContactId)
{
result.string(AttributeRelationUtils.getAttribute($AttributeRegistry.paymentTerm(), orgContactId));
}
}
}
\ No newline at end of file
......@@ -292,6 +292,24 @@ ContactUtils.getPersOrgIds = function(pContactId)
return [];
}
/**
* get the contactId from the OrganisationId
*
* @param {String} pOrgId
* @return {String} the contactId or ""
*/
ContactUtils.getOrgContactId = function(pOrgId)
{
if (pOrgId) {
return db.cell(SqlCondition.begin()
.andPrepare("CONTACT.ORGANISATION_ID", pOrgId)
.and("CONTACT.PERSON_ID is null")
.buildSql("select CONTACTID from CONTACT", "1=0"));
}
return "";
}
/**
* get the name of the person or organisation
*
......
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