====== Contacts & Contact Responsibilities ======
Author: Michelle McCausland
**Note:** Use the queries in the sections below to learn how these tables are linked together.
===== Contacts =====
Contacts are types of users that are assigned to network elements via contact responsibilities.
Contacts and contact responsibilities are utilised in the Tickteter application to denote the owner of tickets ( [[onboarding:ticketer:smart_users|Smart Users]] ) or determine the distribution of ticket notifications ( [[onboarding:ticketer:introduction_to_email_templates_creation_modification_and_fields|Introduction to email templates (creation, modification) and fields]] ) .
Information on adding, updating and deleting contacts can be found in the SNMP Manager Admin User Guide which is available on the Errigal support page.
----
===== Contact Responsibilities =====
Contact responsibilities denote a contact's responsibility for a network element.
Information on adding, updating and deleting contact responsibilities can be found in the SNMP Manager Admin User Guide which is available on the Errigal support page.
----
===== SQL to retrieve contacts and their responsibilities =====
//For reference only - please verify all SQL statements before executing.//
SELECT
cr.contact_id as contactId,
c.first_name, ' ' , c.last_name) as login,
cr.responsibility_type as responsibilityType,
ne.id as elementId,
ne.name as neName
FROM
snmp_manager.contact c
JOIN snmp_manager.contact_responsibility cr ON c.id = cr.contact_id
JOIN snmp_manager.network_element ne ON cr.element_id = ne.id
WHERE
cr.contact_id = ;
----
===== SQL to copy contact responsibilities from one contact to another =====
//For reference only - please verify all SQL statements before executing.//
INSERT INTO contact_responsibility (version, element_id, rank, responsibility_type, contact_id)
(SELECT
0 AS version,
cr.element_id AS element_id,
cr.rank AS rank,
cr.responsibility_type AS responsibility_type,
[id of contact that is being copied TO] AS contact_id
FROM
contact_responsibility cr JOIN
contact co ON co.id = cr.contact_id
WHERE
co.id = [id of contact that is being copied FROM]);
----
===== SQL to copy contact responsibilities from one element to another =====
//For reference only - please verify all SQL statements before executing.//
INSERT INTO contact_responsibility (version, element_id, rank, responsibility_type, contact_id)
(SELECT
0 AS version,
[id of element that is being copied TO] AS element_id,
cr.rank AS rank,
cr.responsibility_type AS responsibility_type,
cr.contact_id AS contact_id
FROM
contact_responsibility cr
JOIN network_element ne ON ne.id = cr.element_id
WHERE
ne.id = [id of element that is being copied FROM]);
===== Useful Info =====
* As of the time of writing - 17th May 2017 - There is a constraint in the code that prevents a contact from having more than 1 responsibility type per network element - See [[https://errigal.atlassian.net/browse/IDMS-686|IDMS-686]]