Fixing "UnexpectedEvent" when uploading documents in Sage CRM
I recently had an issue in Sage CRM where documents would fail to upload and show an "UnexpectedEvent" error when using certain document types...
I recently had an issue in Sage CRM where documents would fail to upload and show an "UnexpectedEvent" error when using certain document types:
Cause
I investigated the issue and discovered that this was caused by document Type codes that were longer than 25 characters, even though the database field allowed for up to 50 characters. This is most likely due to a length constraint in eware.dll in Sage CRM.
Solution
The fix is to go through all the document Type codes and change them to have codes less or equal to 25 characters.
-
To determine what codes need to be changed, you can run the following query in the database:
SELECT * FROM Custom_Captions WHERE Capt_Family = 'Libr_Type' AND Capt_FamilyType = 'Choices' AND LEN(Capt_Code) > 25
You should see a list of codes that need to be changed:
-
As a safety precaution, check to make sure that no documents were somehow added with those types by executing the following query:
SELECT * FROM Library WHERE Libr_Type IN ( SELECT Capt_Code FROM Custom_Captions WHERE Capt_Family = 'Libr_Type' AND Capt_FamilyType = 'Choices' AND LEN(Capt_Code) > 25 )
This could happen if documents were uploaded through an API into the document library and it did not throw an error or if the library record for the document was created directly in the database and not through eware.dll. Rather stay safe and just check. If there are documents, then you'll just need to update them to the new, shorter codes that you'll create in the next few steps (see Step 6 for more information).
-
Log into Sage CRM and go to Administration -> Customization -> Translations:
-
Search for all the translations in the LibrType family:
-
Open each caption that you identified as being too long in Step 1 and modify it to be less than 25 characters long.
-
If necessary, update all the existing documents that were using Type codes longer than 25 characters to the new Type code. These documents would have been done in Step 2.
You can do this update through a SQL
UPDATE
statement, however, do so at our own risk. -
You should now be able to upload documents in Sage CRM using those types.
Conclusion
Hopefully this should fix your issue and you can now upload documents using those types. If you still have an issue or find another solution, please leave a comment below so we can assist and learn.
Disclaimer
I do not take any responsibility for any damage done to your system while following this guide. Be cautious and responsible when making changes to your system by making backups and ensuring that you know what consequences any actions you do will have in the system.