Written on : 15/08/2011 21:08 ( more than one month ) Object : Re: How to add user to org tree node on import This is a backend database update method that I am using for version 4.04. I am updating from a MSSQL table with employee information. First, create a 'linked server' in MSSQL to the DoceboDB through an ODBC MySQL driver from my desired database. Then set an 'Additional Field' in Docebo for the Org Chart Name. I have all of the Org Chart names that are to be updated set to the Department in the 'YOURDATABASE' database that has been linked to Docebo. The tables are joined through the 'YOUREMPLOYEE_FIELD' which I have set equal to the userid inside of Docebo. The only catch is, the userid in Docebo must always match the 'YOUREMPLOYEE_FIELD', so you will have to come up with a method of not allowing Admins to change the userid's. Hope this helps.
--Delete the old custom field DELETE FROM OPENQUERY(DOCEBO, 'SELECT * FROM docebodev.core_field_userentry;') WHERE id_common = '1' and id_user IN (SELECT idst FROM OPENQUERY(DOCEBO, 'SELECT idst, userid FROM docebodev.core_user') core_userref inner join [YOURSERVER].[YOURDATABASE].[dbo].[YOURTABLE] ON userid = ('/' + LTRIM(RTRIM(CAST([YOUREMPLOYEE_FIELD]as varchar(30))))) ) --Place the new custom field equal to the OrgChart name insert into openquery(docebo, 'select id_common_son, id_common, id_user, user_entry from docebodev.core_field_userentry') select '0', '1', idst, LTRIM(RTRIM([YOURORGCHART_NAME])) as statuss FROM OPENQUERY(DOCEBO, 'SELECT idst, userid FROM docebodev.core_user') inner join [YOURSERVER].[YOURDATABASE].[dbo].[YOURTABLE] ON userid = ('/' + LTRIM(RTRIM(CAST([YOUREMPLOYEE_FIELD]as varchar(30)))))
--Delete the old OrgChart Associations DELETE FROM OPENQUERY(DOCEBO, 'SELECT * FROM docebodev.core_group_members WHERE idst not in (1,2,3,4,5,6) and core_group_members.idst in (select idst from docebodev.core_group where groupid like "/oc%");') WHERE idstMember IN (SELECT idst FROM OPENQUERY(DOCEBO, 'SELECT idst, userid FROM docebodev.core_user') core_userref inner join [YOURSERVER].[YOURDATABASE].[dbo].[YOURTABLE] ON userid = ('/' + LTRIM(RTRIM(CAST([YOUREMPLOYEE_FIELD]as varchar(30))))) ) --Insert the New OrgChart Associations insert into openquery(docebo, 'select idst, idstMember from docebodev.core_group_members;') SELECT qidst, qidstMember from openquery(docebo, 'select idst as qidst, id_user as qidstMember from docebodev.core_field_userentry inner join (select * from docebodev.core_org_chart inner join docebodev.core_group on core_group.groupid = CONCAT("/oc_", core_org_chart.id_dir) || core_group.groupid = CONCAT("/ocd_", core_org_chart.id_dir)) as org_chart on user_entry=translation;') Message modified by : jebrown5 on : 09/09/2011 17:40 |