Skip to content
Snippets Groups Projects
Commit dcac4aa4 authored by Sascha Schmidt's avatar Sascha Schmidt
Browse files

[Projekt: xRM-ContactManagement][TicketNr.: 2001249][Kopfanrede in Kontakt wird falsch angezeigt]

parent f4715d3e
No related branches found
No related tags found
No related merge requests found
......@@ -1389,6 +1389,9 @@
<name>LETTERSALUTATION</name>
<title>Lettersalutation</title>
</entityField>
<entityField>
<name>contenttitle</name>
</entityField>
</entityFields>
<recordContainers>
<dbRecordContainer>
......@@ -1697,6 +1700,10 @@
<name>LETTERSALUTATION.value</name>
<recordfield>CONTACT.LETTERSALUTATION</recordfield>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>contenttitle.value</name>
<expression>%aditoprj%/entity/Person_entity/recordcontainers/db/recordfieldmappings/contenttitle.value/expression.js</expression>
</dbRecordFieldMapping>
</recordFieldMappings>
<linkInformation>
<linkInformation>
......
import("system.vars");
import("system.result");
import("Util_lib");
import("Contact_lib");
//do not use "FULL_NAME_fieldGroup" here since the field group must not include the orgname
var contact = new Contact();
contact.salutation = vars.get("$field.SALUTATION");
contact.title = vars.get("$field.TITLE");
contact.firstname = vars.get("$field.FIRSTNAME");
contact.middlename = vars.get("$field.MIDDLENAME");
contact.lastname = vars.get("$field.LASTNAME");
contact.organisationName = vars.get("$field.ORGANISATION_NAME");
var renderer = new ContactTitleRenderer(contact, null);
result.string(renderer.asString());
\ No newline at end of file
result.string(vars.get("$field.contenttitle"));
\ No newline at end of file
import("system.vars");
import("system.result");
import("Util_lib");
import("Contact_lib");
//no orgname here since the org-field is in the card-template as separate field
var contact = new Contact();
contact.salutation = vars.get("$field.SALUTATION");
contact.title = vars.get("$field.TITLE");
contact.firstname = vars.get("$field.FIRSTNAME");
contact.middlename = vars.get("$field.MIDDLENAME");
contact.lastname = vars.get("$field.LASTNAME");
var renderer = new ContactTitleRenderer(contact, null);
result.string(renderer.asString());
\ No newline at end of file
result.string(vars.get("$field.contenttitle"));
\ No newline at end of file
import("Contact_lib");
import("system.result");
result.string(ContactUtils.getContactSalutationSubSql(true));
\ No newline at end of file
......@@ -798,6 +798,53 @@ ContactUtils.isDeletable = function (pCurrentContext, pContactId, pPersonId)
.validate();
}
/**
* Gives the contenttitle in right order from salutaion as SubSQL
*
* @param {Boolean} pGetHeadline if you want SALUTATION.HEADLINE as COLUMN
* @param {Boolean} pGetLetterSalutation if you want SALUTATION.LETTERSALUTATION as COLUMN
*
* @return {String} Subsql for DB.expression
*/
ContactUtils.getContactSalutationSubSql = function(pGetHeadline, pGetLetterSalutation)
{
var column;
if(pGetHeadline)
{
column = "SALUTATION.HEADLINE";
}
if(pGetLetterSalutation)
{
column = "SALUTATION.LETTERSALUTATION";
}
var sqlHelper = new SqlMaskingUtils();
var personSelect = "";
var orgSelect = column;
var saltuationPlaceholders = {"'{fn}'": "PERSON.FIRSTNAME", "'{ln}'": "PERSON.LASTNAME", "'{ti}'": "PERSON.TITLE"};
Object.keys(saltuationPlaceholders).forEach(function(placeholder){
let persSelectFront = "REPLACE(";
let persSelectBack = ", " + placeholder + ", " + sqlHelper.isNull(saltuationPlaceholders[placeholder], "''") + ")";
if(!personSelect)
{
personSelect = persSelectFront + column + persSelectBack;
}
else
{
personSelect = persSelectFront + personSelect + persSelectBack;
}
});
var saltuation = newSelect("case when CONTACT.PERSON_ID is null then " + orgSelect + " else " + personSelect + "end")
.from("SALUTATION")
.where("SALUTATION.ISOLANGUAGE = CONTACT.ISOLANGUAGE")
.and(newWhere("SALUTATION.SEX = PERSON.GENDER").or("SALUTATION.SEX is null"))
.and(newWhere("SALUTATION.TITLE = PERSON.TITLE").or("SALUTATION.TITLE is null"))
.and(newWhere("SALUTATION.SALUTATION = PERSON.SALUTATION").or("SALUTATION.SALUTATION is null"))
.orderBy("SALUTATION.SEX desc, SALUTATION.TITLE desc");
saltuation = saltuation.toString();
saltuation = saltuation + " " + sqlHelper.limit(1);
return saltuation;
}
/**
* object for handling of a single contact
* provides static- and instance-functions
......
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