After importing data from Office 365, the import “writers” process fails with logging similar to the following:
2018-08-31 00:33:35,559 [INFO ] Failed to execute Writer 'Create license allocations from ImportedSoftwareLicenseAllocations' from file C:\ProgramData\Flexera Software\Compliance\ImportProcedures\Inventory\Writer\LicenseCreateUpdate.xml
Error: Violation of UNIQUE KEY constraint 'UQ_SoftwareLicenseAllocation'. Cannot insert duplicate key in object 'dbo.SoftwareLicenseAllocation_MT'. The duplicate key value is (293, <NULL>, 8391, <NULL>, <NULL>, <NULL>, <NULL>).
The statement has been terminated.
Added 0 new user allocation(s) from the source database connections.
This issue can be caused by the query logic used in the “Create license allocations from ImportedSoftwareLicenseAllocations” procedure being unable to handle a situation where a user record is linked to multiple imported user details.
Make a backup copy of the following file on the batch server: C:\ProgramData\Flexera Software\Compliance\ImportProcedures\Inventory\Writer\LicenseCreateUpdate.xml.
Edit the LicenseCreateUpdate.xml file in a text editor, and locate the “Create license allocations from ImportedSoftwareLicenseAllocations” writer in that file.
Add the “DISTINCT” keyword to the line “SELECT sl.SoftwareLicenseID” as shown towards the end of the following extract: