Article
Bug mobile report: an error during the file writing process (relevant for iOS) - occurs due to special characters in the file name
15:49 Apr 05, 2018
Symptoms
Bug mobile report:
Type: Terrasoft.SyncException Message: Error during synchronization Stack trace: Type: Terrasoft.FileException Message: An error occured during the file writing process AdditionalInfo: Name: BPMonline700/Downloads/6005bfc5-5ea7-42da-82e6-15f5f4c9e80a/invoice for payment #6.pdf Type: Terrasoft.FileSystemException Message: undefined AdditionalInfo: Code: undefined Data: 4 Model Name: iPhone8,2 (0x0) Platform: iOS Platform Version: 9.2.1 IsOnlineMode: false UIVersion: 2 ApplicationVersion: 7.7.8 ApplicationMajorVersion: 7.7 ContactId: c41b4784-a414-438c-a846-c5bf418f0056 CultureName: en-US ApplicationRevision: 0 BackgroundSyncMode: 3 WorkplaceCode: DefaultWorkplace
Cause
This error occurs due to the fact the file on the “Attachments” detail incudes a special character in its name (for example, the "#" symbol) - the iOS platform restricts the use of special characters when sending requests/files.
Solution
Rename the file and remove the “#” symbol. To do this, either:
- find the file and rename it manually;
- Find the parent object in the database using its ID (for example, «6005bfc5-5ea7-42da-82e6-15f5f4c9e80a») and determine its exact location in the application. Either use the database tools to rename it, or rename the located file on the application level. The following script can be used to locate the object in which the file is stored on the database:
-- Incoming parameters - coulmn name and value: DECLARE @COLUMN_NAME NVarChar(100) = 'Id' DECLARE @COLUMN_VALUE NVarChar(100) = '6005bfc5-5ea7-42da-82e6-15f5f4c9e80a' DECLARE @tableName VARCHAR(50) DECLARE tablesCursor CURSOR LOCAL FORWARD_ONLY STATIC FOR -- The request returns the names of the database tables which include the @COLUMN_VALUE column: SELECT table_name = sysobjects.name FROM sysobjects JOIN syscolumns ON sysobjects.id = syscolumns.id WHERE sysobjects.xtype='U' and syscolumns.name = @COLUMN_NAME OPEN tablesCursor FETCH NEXT FROM tablesCursor INTO @tableName WHILE @@FETCH_STATUS = 0 BEGIN -- If a table @COLUMN_NAME has a @COLUMN_VALUE value - -- display the table name, query, and the number of rows in the EXEC request ('DECLARE @recordCount INT; DECLARE @quotesChar CHAR = char(39); DECLARE @tabChar CHAR = char(9); BEGIN TRY SET @recordCount = (SELECT COUNT(*) FROM [' + @tableName + '] where ' + @COLUMN_NAME + ' = ''' + @COLUMN_VALUE + ''') IF @recordCount > 0 BEGIN PRINT '''' PRINT ''-- ' + @tableName + ':'' PRINT '' SELECT * FROM ' + @tableName + ' WHERE ' + @COLUMN_NAME + ' = '' + @quotesChar + ''' + @COLUMN_VALUE + ''' + @quotesChar + '''' PRINT '' -- Number of rows in request: '' + CAST(@recordCount as VARCHAR(5)) END END TRY BEGIN CATCH END CATCH; '); FETCH NEXT FROM tablesCursor INTO @tableName END CLOSE tablesCursor DEALLOCATE tablesCursor