Skip to content
Snippets Groups Projects
Commit 7726e7fa authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

Merge branch '#1071012-LedimportStandartadresse' into '2021.0.0'

#1071012-LedimportStandartadresse Organisation Address is set as main Address in the contact

See merge request xrm/basic!631
parents d19d894a a937dd26
No related branches found
No related tags found
No related merge requests found
......@@ -163,14 +163,15 @@ LeadImportUtils.importData = function(pDataFields, pDataTypes, pFieldDef, pField
var orgObjID = "";
var orgsForDubCheck = "";
var persForDubCheck = "";
var orgRet;
var orgAddressID = null;
var orgRet = [null, null, null, null];
var persRet;
//------create organisation
if (LeadValues["NAME"].trim() != "")//only if Organame is filled
{
orgObjID = "Organisation";//for attribute
orgRet = LeadImportUtils.insertOrg(pDataFields, pDataTypes, pFieldDef, pFieldValues, pUser, pDate);
[orgRet[0], orgRet[1], orgRet[2], orgRet[3], orgAddressID] = LeadImportUtils.insertOrg(pDataFields, pDataTypes, pFieldDef, pFieldValues, pUser, pDate);
orgid = orgRet[0];
orgContactId = orgRet[1];
......@@ -186,7 +187,7 @@ LeadImportUtils.importData = function(pDataFields, pDataTypes, pFieldDef, pField
if (LeadValues["LASTNAME"].trim() != "")//only if lastname is filled
{
persObjID = "Person";//for attribute
persRet = LeadImportUtils.insertPers(pDataFields, pDataTypes, pFieldDef, pFieldValues, orgid, LeadValues, pUser, pDate);
persRet = LeadImportUtils.insertPers(pDataFields, pDataTypes, pFieldDef, pFieldValues, orgid, LeadValues, pUser, pDate, orgAddressID);
persid = persRet[0];
persContactId = persRet[1];
......@@ -574,11 +575,11 @@ LeadImportUtils.insertOrg = function(pDataFields, pDataTypes, pFieldDef, pField
workflow.startProcessByKey("leadprocess", processVariables)
}
return new Array(orgid, contactId ,entityFieldValues, true);
return new Array(orgid, contactId ,entityFieldValues, true, ContactValues["ADDRESS_ID"]);
}
//return the ids of the existing organisation so that people who work for the same organisation are assigned to them
// OrgId ContactID
return new Array(ids[0], ids[1] ,entityFieldValues, false);
return new Array(ids[0], ids[1] ,entityFieldValues, false, ids[2]);
}
/**
......@@ -595,7 +596,7 @@ LeadImportUtils.insertOrg = function(pDataFields, pDataTypes, pFieldDef, pField
*
* @return {String []} (personId, contactId, duplicateMapping)
*/
LeadImportUtils.insertPers = function(pDataFields, pDataTypes, pFieldDef, pFieldValues, pOrgId, pLeadValues, pUser, pDate)
LeadImportUtils.insertPers = function(pDataFields, pDataTypes, pFieldDef, pFieldValues, pOrgId, pLeadValues, pUser, pDate, pOrgAddressID)
{
var isoLanguage = pLeadValues["ISOLANGUAGE"];
......@@ -611,7 +612,6 @@ LeadImportUtils.insertPers = function(pDataFields, pDataTypes, pFieldDef, pFiel
ContactValues["STATUS"] = "CONTACTSTATACTIVE";//only insert active persons
ContactValues["PERSON_ID"] = persid;
ContactValues["ADDRESS_ID"] = util.getNewUUID();
ContactValues["DEPARTMENT"] = ContactInfoUtils.getContactDepartment(pLeadValues);
ContactValues["CONTACTROLE"] = ContactInfoUtils.getContactRole(pLeadValues);
ContactValues["CONTACTPOSITION"] = ContactInfoUtils.getContactPosition(pLeadValues);
......@@ -624,14 +624,14 @@ LeadImportUtils.insertPers = function(pDataFields, pDataTypes, pFieldDef, pFiel
else
{
ContactValues["ORGANISATION_ID"] = pOrgId;
ContactValues["ADDRESS_ID"] = 0
ContactValues["ADDRESS_ID"] = pOrgAddressID
}
var contactId = LeadImportUtils.insertTable(pDataFields, pDataTypes, ContactValues, "CONTACT", pUser, pDate);
//Address
if (ContactValues["ADDRESS_ID"])
if (ContactValues["ADDRESS_ID"] && !ContactValues["ORGANISATION_ID"])
{
var AddrValues = LeadImportUtils.setValues(pDataFields["ADDRESS"], pFieldDef, pFieldValues);
AddrValues["ADDRESSID"] = ContactValues["ADDRESS_ID"];
......@@ -954,7 +954,7 @@ LeadImportUtils.scanLeadDups = function(pAllContactData)
LeadImportUtils.checkOrgDup = function(pLeadValues)
{
// search whether the organisation already exists
var query = newSelect("ORGANISATIONID, CONTACTID")
var query = newSelect(["ORGANISATIONID, CONTACTID, ADDRESSID"])
.from("ORGANISATION")
.join("CONTACT", "ORGANISATIONID = CONTACT.ORGANISATION_ID")
.join("ADDRESS", "ADDRESSID = ADDRESS_ID");
......
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