Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
basic
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Gitlab Maintenance 11.04.2025 | 20:00 - 23:00 MEZ
Show more breadcrumbs
xrm
basic
Commits
a2c9573b
Commit
a2c9573b
authored
5 years ago
by
Johannes Goderbauer
Browse files
Options
Downloads
Patches
Plain Diff
Communication: Fix of setting standard if no category is given
parent
126e8354
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
process/StandardObject_lib/process.js
+317
-314
317 additions, 314 deletions
process/StandardObject_lib/process.js
with
317 additions
and
314 deletions
process/StandardObject_lib/process.js
+
317
−
314
View file @
a2c9573b
import
(
"
system.db
"
);
import
(
"
Keyword_lib
"
);
import
(
"
KeywordRegistry_basic
"
);
import
(
"
Contact_lib
"
);
import
(
"
Communication_lib
"
);
function
StandardObject
(
pObjectType
,
pObjectID
,
pScopeType
,
pScopeID
)
{
if
(
!
this
.
_isValidType
(
"
object
"
,
pObjectType
))
throw
new
Error
(
"
StandardObject: Invalid object type
"
)
if
(
!
this
.
_isValidType
(
"
scope
"
,
pScopeType
))
throw
new
Error
(
"
StandardObject: Invalid scope type
"
)
this
.
objectType
=
pObjectType
this
.
objectID
=
pObjectID
this
.
scopeType
=
pScopeType
this
.
scopeID
=
pScopeID
}
StandardObject
.
CONST_OBJECT_ADDRESS
=
function
()
{
return
"
Address
"
}
StandardObject
.
CONST_OBJECT_COMMUNICATION
=
function
()
{
return
"
Communication
"
}
StandardObject
.
CONST_SCOPE_PERSON
=
function
()
{
return
"
Person
"
}
StandardObject
.
CONST_SCOPE_ORGANISATION
=
function
()
{
return
"
Organisation
"
}
StandardObject
.
prototype
.
_isValidType
=
function
(
pFor
,
pType
)
{
var
validObjectTypes
=
[
"
Address
"
,
"
Communication
"
]
var
validScopeTypes
=
[
"
Person
"
,
"
Organisation
"
]
if
(
pFor
===
"
object
"
)
{
return
validObjectTypes
.
indexOf
(
pType
)
!==
-
1
}
else
if
(
pFor
===
"
scope
"
){
return
validScopeTypes
.
indexOf
(
pType
)
!==
-
1
}
else
{
return
false
;
}
}
/**
* Asserts the object type of this instance against the
* given type.
*
* @throws Error if assertion fails.
*/
StandardObject
.
prototype
.
_assertObjectType
=
function
(
pType
)
{
if
(
this
.
objectType
!==
pType
)
throw
new
Error
(
"
Object assertion: Invalid type
"
);
}
/**
* Asserts the scope type of this instance against the
* given type.
*
* @throws Error if assertion fails.
*/
StandardObject
.
prototype
.
_assertScopeType
=
function
(
pType
)
{
if
(
this
.
scopeType
!==
pType
)
throw
new
Error
(
"
Scope assertion: Invalid type
"
);
}
/**
* Asserts that the object ID is NOT null.
*
* @throws Error if assertion fails.
*/
StandardObject
.
prototype
.
_assertObjectIdNotNull
=
function
()
{
if
(
this
.
objectID
===
null
)
throw
new
Error
(
"
Object assertion: ID is null
"
);
}
/**
* Asserts that the scope ID is NOT null.
*
* @throws Error if assertion fails.
*/
StandardObject
.
prototype
.
_assertScopeIdNotNull
=
function
()
{
if
(
this
.
scopeID
===
null
)
throw
new
Error
(
"
Scope assertion: ID is null
"
);
}
/**
* Shall be executed in the `valueProcess` of the `ADDRESS_ID` in the
* `Person` entity. This function will take care about the standard address
* of the linked organisation.o
*
* @param pSelectedOrganisationID The ID of the currently selected organisation.
* @return Standard address to apply to the field or null
* (if no standard address was found)
*/
StandardObject
.
prototype
.
onPersonValueChange
=
function
(
pSelectedOrganisationID
)
{
this
.
_assertScopeIdNotNull
();
// Check if the organisation has an standard address
var
addressID
=
this
.
_getCompanyStandardAddress
(
pSelectedOrganisationID
);
return
addressID
;
}
/**
* Shall be executed on the `onDBInsert` process of the recordContainer
* of the object type (Address or Communication). This algorithm works
* on a "random" basis: Which object gets first inserted will get the
* place as standard.
*/
StandardObject
.
prototype
.
onObjectInsert
=
function
()
{
this
.
_assertObjectIdNotNull
();
this
.
_assertScopeIdNotNull
();
if
(
this
.
objectType
===
StandardObject
.
CONST_OBJECT_ADDRESS
())
{
this
.
_onAddressInsert
();
}
else
if
(
this
.
objectType
===
StandardObject
.
CONST_OBJECT_COMMUNICATION
)
{
this
.
_onCommunicationInsert
();
}
}
/**
* Shall be execute only on the `onDBInsert` process of the recordContainer
* of the `Address` entity. This will set the standard address on the
* contact if it's currently null.
*/
StandardObject
.
prototype
.
_onAddressInsert
=
function
()
{
// Assert
this
.
_assertObjectType
(
StandardObject
.
CONST_OBJECT_ADDRESS
());
if
(
!
this
.
_hasContactStandardAddress
(
this
.
scopeID
))
{
this
.
_setContactStandardAddress
(
this
.
objectID
,
this
.
scopeID
);
}
}
StandardObject
.
prototype
.
onPersonUpdate
=
function
(
pOrganisationID
)
{
// Assert
this
.
_assertScopeType
(
StandardObject
.
CONST_SCOPE_PERSON
());
var
isOrganisationAddress
=
this
.
_isOrganisationAddress
(
this
.
scopeID
);
if
(
isOrganisationAddress
)
{
// Update to new address of org
var
addressID
=
this
.
_getCompanyStandardAddress
(
pOrganisationID
);
this
.
_setContactStandardAddress
(
addressID
,
this
.
scopeID
);
}
}
StandardObject
.
prototype
.
onCommunicationInsert
=
function
(
pMediumID
)
{
// Assert
this
.
_assertObjectType
(
StandardObject
.
CONST_OBJECT_COMMUNICATION
());
this
.
_assertObjectIdNotNull
();
this
.
_assertScopeIdNotNull
();
var
mediumCategory
=
this
.
_getMediumCategory
(
pMediumID
);
var
hasStandard
=
this
.
_hasStandardCommunicationByMedium
(
this
.
scopeID
,
mediumCategory
);
if
(
!
hasStandard
)
{
this
.
_setStandardCommunication
(
this
.
objectID
,
1
);
}
}
StandardObject
.
prototype
.
onCommunicationUpdate
=
function
(
pMediumID
)
{
// Assert
this
.
_assertObjectType
(
StandardObject
.
CONST_OBJECT_COMMUNICATION
());
this
.
_assertObjectIdNotNull
();
this
.
_assertScopeIdNotNull
();
this
.
_setStandardCommunication
(
this
.
objectID
,
0
);
var
mediumCategory
=
this
.
_getMediumCategory
(
pMediumID
);
var
contactID
=
this
.
_getContactIdByCommunication
(
this
.
objectID
);
var
hasStandard
=
this
.
_hasStandardCommunicationByMedium
(
contactID
,
mediumCategory
);
if
(
!
hasStandard
)
this
.
_setStandardCommunication
(
this
.
objectID
,
1
);
}
/**
* Checks if the given contact ID has any address ID set. If there is a standard
* address it will return `true`, otherwise `false`. This function asserts that
* it's currently working on a `Address` object.
*
* @param {String} pContactID Contact ID to check.
* @return {Boolean} If the contact ID has standard address.
*/
StandardObject
.
prototype
.
_hasContactStandardAddress
=
function
(
pContactID
)
{
this
.
_assertObjectType
(
StandardObject
.
CONST_OBJECT_ADDRESS
());
var
databaseResult
=
db
.
cell
(
"
select ADDRESS_ID from CONTACT
"
+
"
where CONTACTID = '
"
+
pContactID
+
"
'
"
);
return
databaseResult
!==
""
;
}
/**
* Will set the given address ID on the given contact ID. This function asserts
* that it's currently working on an `Address` object.
*
* @param {String} pAddressID New address ID to set on the contact.
* @param {String} pContactID The contact ID to set the address ID on.
*/
StandardObject
.
prototype
.
_setContactStandardAddress
=
function
(
pAddressID
,
pContactID
)
{
// Assert.
this
.
_assertObjectType
(
StandardObject
.
CONST_OBJECT_ADDRESS
());
// Update data.
db
.
updateData
(
"
CONTACT
"
,
[
"
ADDRESS_ID
"
],
db
.
getColumnTypes
(
"
CONTACT
"
,
[
"
ADDRESS_ID
"
]),
[
pAddressID
],
"
CONTACTID = '
"
+
pContactID
+
"
'
"
);
}
/**
* Will return the standard address of the given organisation. If the organisation
* has no standard address set it will just return null.
*
* @return Standard address of the organisation or null.
*/
StandardObject
.
prototype
.
_getCompanyStandardAddress
=
function
(
pOrganisationID
)
{
var
addressIdResult
=
db
.
cell
(
"
select ADDRESS_ID from CONTACT
"
+
"
where ORGANISATION_ID = '
"
+
pOrganisationID
+
"
'
"
+
"
and ADDRESS_ID is not null and PERSON_ID is null
"
);
if
(
addressIdResult
===
""
)
return
null
;
return
addressIdResult
;
}
/**
* Checks if the given contact ID already has a standard set with the given medium
* category.
*
* @param {String} pContactID Contact ID to check.
* @param {String} pMediumCategory Medium category to check.
* @return {Boolean} If the contact already has a standard addres with the given
* medium category.
*/
StandardObject
.
prototype
.
_hasStandardCommunicationByMedium
=
function
(
pContactID
,
pMediumCategory
)
{
var
dbResult
=
db
.
array
(
db
.
COLUMN
,
"
select CHAR_VALUE from COMMUNICATION
"
+
"
left join AB_KEYWORD_ENTRY on KEYID = MEDIUM_ID
"
+
"
left join AB_KEYWORD_ATTRIBUTERELATION on AB_KEYWORD_ENTRY_ID = AB_KEYWORD_ENTRYID
"
+
"
where STANDARD = 1 and CONTACT_ID = '
"
+
pContactID
+
"
' and KEYID in ('
"
+
CommUtil
.
getMediumIdsByCategory
(
pMediumCategory
).
join
(
"
', '
"
)
+
"
')
"
);
return
dbResult
.
indexOf
(
pMediumCategory
)
!==
-
1
;
}
/**
* Resolves the given pMediumID with the category.
*
* @param {String} pMediumID ID of the medium to resolve.
* @return {String} Resovled category.
*/
StandardObject
.
prototype
.
_getMediumCategory
=
function
(
pMediumID
)
{
var
categories
=
KeywordUtils
.
getAttributeRelationsByKey
(
pMediumID
,
$KeywordRegistry
.
communicationMedium
())
return
categories
.
category
;
}
/**
* Will set the given communication ID as standard. (Will update the `STANDARD`
* column.)
*
* @param {String} pCommunicationID The communication ID to set as standard.
* @param {Number} pValue 0 or 1 (boolean)
*/
StandardObject
.
prototype
.
_setStandardCommunication
=
function
(
pCommunicationID
,
pValue
)
{
// Assert.
this
.
_assertObjectType
(
StandardObject
.
CONST_OBJECT_COMMUNICATION
());
// Update data.
db
.
updateData
(
"
COMMUNICATION
"
,
[
"
STANDARD
"
],
db
.
getColumnTypes
(
"
COMMUNICATION
"
,
[
"
STANDARD
"
]),
[
pValue
],
"
COMMUNICATIONID = '
"
+
pCommunicationID
+
"
'
"
);
}
/**
* Will return the Contact ID by the given communication ID.
*
* @param {String} pCommunicationID to get the contact ID for.
* @return The contact ID.
*/
StandardObject
.
prototype
.
_getContactIdByCommunication
=
function
(
pCommunicationID
)
{
return
db
.
cell
(
"
select CONTACT_ID from COMMUNICATION where COMMUNICATIONID = '
"
+
pCommunicationID
+
"
'
"
);
}
StandardObject
.
prototype
.
_isOrganisationAddress
=
function
(
pAddressID
)
{
return
StandardObject
.
isOrganisationAddress
(
pAddressID
);
}
/**
* Check if the address is a organisation address.
*
* @param {String} pAddressID Communication ID to get the contact ID for.
* @return The contact ID.
*/
StandardObject
.
isOrganisationAddress
=
function
(
pAddressID
)
{
var
contactID
=
db
.
cell
(
"
select CONTACTID from CONTACT where ADDRESS_ID = '
"
+
pAddressID
+
"
'
"
);
if
(
!
contactID
)
return
false
;
var
contactType
=
ContactUtils
.
getContactTypeByContactId
(
contactID
);
return
contactType
==
1
;
import
(
"
system.db
"
);
import
(
"
Keyword_lib
"
);
import
(
"
KeywordRegistry_basic
"
);
import
(
"
Contact_lib
"
);
import
(
"
Communication_lib
"
);
function
StandardObject
(
pObjectType
,
pObjectID
,
pScopeType
,
pScopeID
)
{
if
(
!
this
.
_isValidType
(
"
object
"
,
pObjectType
))
throw
new
Error
(
"
StandardObject: Invalid object type
"
)
if
(
!
this
.
_isValidType
(
"
scope
"
,
pScopeType
))
throw
new
Error
(
"
StandardObject: Invalid scope type
"
)
this
.
objectType
=
pObjectType
this
.
objectID
=
pObjectID
this
.
scopeType
=
pScopeType
this
.
scopeID
=
pScopeID
}
StandardObject
.
CONST_OBJECT_ADDRESS
=
function
()
{
return
"
Address
"
}
StandardObject
.
CONST_OBJECT_COMMUNICATION
=
function
()
{
return
"
Communication
"
}
StandardObject
.
CONST_SCOPE_PERSON
=
function
()
{
return
"
Person
"
}
StandardObject
.
CONST_SCOPE_ORGANISATION
=
function
()
{
return
"
Organisation
"
}
StandardObject
.
prototype
.
_isValidType
=
function
(
pFor
,
pType
)
{
var
validObjectTypes
=
[
"
Address
"
,
"
Communication
"
]
var
validScopeTypes
=
[
"
Person
"
,
"
Organisation
"
]
if
(
pFor
===
"
object
"
)
{
return
validObjectTypes
.
indexOf
(
pType
)
!==
-
1
}
else
if
(
pFor
===
"
scope
"
){
return
validScopeTypes
.
indexOf
(
pType
)
!==
-
1
}
else
{
return
false
;
}
}
/**
* Asserts the object type of this instance against the
* given type.
*
* @throws Error if assertion fails.
*/
StandardObject
.
prototype
.
_assertObjectType
=
function
(
pType
)
{
if
(
this
.
objectType
!==
pType
)
throw
new
Error
(
"
Object assertion: Invalid type
"
);
}
/**
* Asserts the scope type of this instance against the
* given type.
*
* @throws Error if assertion fails.
*/
StandardObject
.
prototype
.
_assertScopeType
=
function
(
pType
)
{
if
(
this
.
scopeType
!==
pType
)
throw
new
Error
(
"
Scope assertion: Invalid type
"
);
}
/**
* Asserts that the object ID is NOT null.
*
* @throws Error if assertion fails.
*/
StandardObject
.
prototype
.
_assertObjectIdNotNull
=
function
()
{
if
(
this
.
objectID
===
null
)
throw
new
Error
(
"
Object assertion: ID is null
"
);
}
/**
* Asserts that the scope ID is NOT null.
*
* @throws Error if assertion fails.
*/
StandardObject
.
prototype
.
_assertScopeIdNotNull
=
function
()
{
if
(
this
.
scopeID
===
null
)
throw
new
Error
(
"
Scope assertion: ID is null
"
);
}
/**
* Shall be executed in the `valueProcess` of the `ADDRESS_ID` in the
* `Person` entity. This function will take care about the standard address
* of the linked organisation.o
*
* @param pSelectedOrganisationID The ID of the currently selected organisation.
* @return Standard address to apply to the field or null
* (if no standard address was found)
*/
StandardObject
.
prototype
.
onPersonValueChange
=
function
(
pSelectedOrganisationID
)
{
this
.
_assertScopeIdNotNull
();
// Check if the organisation has an standard address
var
addressID
=
this
.
_getCompanyStandardAddress
(
pSelectedOrganisationID
);
return
addressID
;
}
/**
* Shall be executed on the `onDBInsert` process of the recordContainer
* of the object type (Address or Communication). This algorithm works
* on a "random" basis: Which object gets first inserted will get the
* place as standard.
*/
StandardObject
.
prototype
.
onObjectInsert
=
function
()
{
this
.
_assertObjectIdNotNull
();
this
.
_assertScopeIdNotNull
();
if
(
this
.
objectType
===
StandardObject
.
CONST_OBJECT_ADDRESS
())
{
this
.
_onAddressInsert
();
}
else
if
(
this
.
objectType
===
StandardObject
.
CONST_OBJECT_COMMUNICATION
)
{
this
.
_onCommunicationInsert
();
}
}
/**
* Shall be execute only on the `onDBInsert` process of the recordContainer
* of the `Address` entity. This will set the standard address on the
* contact if it's currently null.
*/
StandardObject
.
prototype
.
_onAddressInsert
=
function
()
{
// Assert
this
.
_assertObjectType
(
StandardObject
.
CONST_OBJECT_ADDRESS
());
if
(
!
this
.
_hasContactStandardAddress
(
this
.
scopeID
))
{
this
.
_setContactStandardAddress
(
this
.
objectID
,
this
.
scopeID
);
}
}
StandardObject
.
prototype
.
onPersonUpdate
=
function
(
pOrganisationID
)
{
// Assert
this
.
_assertScopeType
(
StandardObject
.
CONST_SCOPE_PERSON
());
var
isOrganisationAddress
=
this
.
_isOrganisationAddress
(
this
.
scopeID
);
if
(
isOrganisationAddress
)
{
// Update to new address of org
var
addressID
=
this
.
_getCompanyStandardAddress
(
pOrganisationID
);
this
.
_setContactStandardAddress
(
addressID
,
this
.
scopeID
);
}
}
StandardObject
.
prototype
.
onCommunicationInsert
=
function
(
pMediumID
)
{
// Assert
this
.
_assertObjectType
(
StandardObject
.
CONST_OBJECT_COMMUNICATION
());
this
.
_assertObjectIdNotNull
();
this
.
_assertScopeIdNotNull
();
var
mediumCategory
=
this
.
_getMediumCategory
(
pMediumID
);
var
hasStandard
=
this
.
_hasStandardCommunicationByMedium
(
this
.
scopeID
,
mediumCategory
);
if
(
!
hasStandard
)
{
this
.
_setStandardCommunication
(
this
.
objectID
,
1
);
}
}
StandardObject
.
prototype
.
onCommunicationUpdate
=
function
(
pMediumID
)
{
// Assert
this
.
_assertObjectType
(
StandardObject
.
CONST_OBJECT_COMMUNICATION
());
this
.
_assertObjectIdNotNull
();
this
.
_assertScopeIdNotNull
();
this
.
_setStandardCommunication
(
this
.
objectID
,
0
);
var
mediumCategory
=
this
.
_getMediumCategory
(
pMediumID
);
if
(
!
mediumCategory
)
return
null
;
var
contactID
=
this
.
_getContactIdByCommunication
(
this
.
objectID
);
var
hasStandard
=
this
.
_hasStandardCommunicationByMedium
(
contactID
,
mediumCategory
);
if
(
!
hasStandard
)
this
.
_setStandardCommunication
(
this
.
objectID
,
1
);
return
null
;
}
/**
* Checks if the given contact ID has any address ID set. If there is a standard
* address it will return `true`, otherwise `false`. This function asserts that
* it's currently working on a `Address` object.
*
* @param {String} pContactID Contact ID to check.
* @return {Boolean} If the contact ID has standard address.
*/
StandardObject
.
prototype
.
_hasContactStandardAddress
=
function
(
pContactID
)
{
this
.
_assertObjectType
(
StandardObject
.
CONST_OBJECT_ADDRESS
());
var
databaseResult
=
db
.
cell
(
"
select ADDRESS_ID from CONTACT
"
+
"
where CONTACTID = '
"
+
pContactID
+
"
'
"
);
return
databaseResult
!==
""
;
}
/**
* Will set the given address ID on the given contact ID. This function asserts
* that it's currently working on an `Address` object.
*
* @param {String} pAddressID New address ID to set on the contact.
* @param {String} pContactID The contact ID to set the address ID on.
*/
StandardObject
.
prototype
.
_setContactStandardAddress
=
function
(
pAddressID
,
pContactID
)
{
// Assert.
this
.
_assertObjectType
(
StandardObject
.
CONST_OBJECT_ADDRESS
());
// Update data.
db
.
updateData
(
"
CONTACT
"
,
[
"
ADDRESS_ID
"
],
db
.
getColumnTypes
(
"
CONTACT
"
,
[
"
ADDRESS_ID
"
]),
[
pAddressID
],
"
CONTACTID = '
"
+
pContactID
+
"
'
"
);
}
/**
* Will return the standard address of the given organisation. If the organisation
* has no standard address set it will just return null.
*
* @return Standard address of the organisation or null.
*/
StandardObject
.
prototype
.
_getCompanyStandardAddress
=
function
(
pOrganisationID
)
{
var
addressIdResult
=
db
.
cell
(
"
select ADDRESS_ID from CONTACT
"
+
"
where ORGANISATION_ID = '
"
+
pOrganisationID
+
"
'
"
+
"
and ADDRESS_ID is not null and PERSON_ID is null
"
);
if
(
addressIdResult
===
""
)
return
null
;
return
addressIdResult
;
}
/**
* Checks if the given contact ID already has a standard set with the given medium
* category.
*
* @param {String} pContactID Contact ID to check.
* @param {String} pMediumCategory Medium category to check.
* @return {Boolean} If the contact already has a standard addres with the given
* medium category.
*/
StandardObject
.
prototype
.
_hasStandardCommunicationByMedium
=
function
(
pContactID
,
pMediumCategory
)
{
var
dbResult
=
db
.
array
(
db
.
COLUMN
,
"
select CHAR_VALUE from COMMUNICATION
"
+
"
left join AB_KEYWORD_ENTRY on KEYID = MEDIUM_ID
"
+
"
left join AB_KEYWORD_ATTRIBUTERELATION on AB_KEYWORD_ENTRY_ID = AB_KEYWORD_ENTRYID
"
+
"
where STANDARD = 1 and CONTACT_ID = '
"
+
pContactID
+
"
' and KEYID in ('
"
+
CommUtil
.
getMediumIdsByCategory
(
pMediumCategory
).
join
(
"
', '
"
)
+
"
')
"
);
return
dbResult
.
indexOf
(
pMediumCategory
)
!==
-
1
;
}
/**
* Resolves the given pMediumID with the category.
*
* @param {String} pMediumID ID of the medium to resolve.
* @return {String} Resovled category.
*/
StandardObject
.
prototype
.
_getMediumCategory
=
function
(
pMediumID
)
{
var
categories
=
KeywordUtils
.
getAttributeRelationsByKey
(
pMediumID
,
$KeywordRegistry
.
communicationMedium
())
return
categories
.
category
;
}
/**
* Will set the given communication ID as standard. (Will update the `STANDARD`
* column.)
*
* @param {String} pCommunicationID The communication ID to set as standard.
* @param {Number} pValue 0 or 1 (boolean)
*/
StandardObject
.
prototype
.
_setStandardCommunication
=
function
(
pCommunicationID
,
pValue
)
{
// Assert.
this
.
_assertObjectType
(
StandardObject
.
CONST_OBJECT_COMMUNICATION
());
// Update data.
db
.
updateData
(
"
COMMUNICATION
"
,
[
"
STANDARD
"
],
db
.
getColumnTypes
(
"
COMMUNICATION
"
,
[
"
STANDARD
"
]),
[
pValue
],
"
COMMUNICATIONID = '
"
+
pCommunicationID
+
"
'
"
);
}
/**
* Will return the Contact ID by the given communication ID.
*
* @param {String} pCommunicationID to get the contact ID for.
* @return The contact ID.
*/
StandardObject
.
prototype
.
_getContactIdByCommunication
=
function
(
pCommunicationID
)
{
return
db
.
cell
(
"
select CONTACT_ID from COMMUNICATION where COMMUNICATIONID = '
"
+
pCommunicationID
+
"
'
"
);
}
StandardObject
.
prototype
.
_isOrganisationAddress
=
function
(
pAddressID
)
{
return
StandardObject
.
isOrganisationAddress
(
pAddressID
);
}
/**
* Check if the address is a organisation address.
*
* @param {String} pAddressID Communication ID to get the contact ID for.
* @return The contact ID.
*/
StandardObject
.
isOrganisationAddress
=
function
(
pAddressID
)
{
var
contactID
=
db
.
cell
(
"
select CONTACTID from CONTACT where ADDRESS_ID = '
"
+
pAddressID
+
"
'
"
);
if
(
!
contactID
)
return
false
;
var
contactType
=
ContactUtils
.
getContactTypeByContactId
(
contactID
);
return
contactType
==
1
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment