Removes the attached file specified by a position in the named field of the specified table record.
Use the EWRemoveAttached call to remove an attached file from a File or Image field in a record in the table.
Rules and Guidelines
When removing attached files, consider the following rules and guidelines:
- The username that was used to obtain the specified session token must have sufficient access rights to modify individual records within the specified table. Please verify specific permissions via Setup > Access > Manage Groups > (Edit Group) > Table > (Edit Table) > Permissions.
- Agiloft allows specifying fine-grained access permissions on the field level. The username that was used to obtain the specified session token must have sufficient access rights to be able to update field content. Please verify specific permissions via Setup > Access > Manage Groups > (Edit Group) > Table > (Edit Table) > Field Permissions.
- This call requires the position of the attached file in the specified field. Position numbering starts from 0.
- One can use the EWRead method to obtain an array of file names for the attached field in the specified field. The sequence of file names in the array will correspond to the positions of the files.
- Only one file per call is removed.
- In general, you use EWRemoveAttached when you know in advance the IDs of the records to retrieve. The client application may use the likes of EWSelectFromTable call to obtain record identifiers beforehand or take the identifiers from the id field of the data structures and linking classes.
Basic Steps for Removing Attached Files
Removing files from records involves the following basic steps:
- Determine the id of the record you want to update. You may want to use the EWSelectFromTable or EWSearchTable calls to get the identifier of the record based on some search condition or get the identifier from a previous EWCreate call, or get the id of a linked record from the linking class after performing EWRead or EWUpdate.
- Determine the position of the file in the field.
- Call EWRemoveAttached.
- Process the results.
In MyKB knowledgebase, as user A, remove all files named B.txt currently attached in the field Additional Files of case #456 and return the total number of files currently attached.
The task is completed by performing the following steps:
- Login to MyKB with "A" and "password" and English as the local language.
- Read the record to get the list of the files.
- Find the position of the file.
- Invoke the remove file call.
- Get the total number of files currently attached.
Sample Code - Java
You can generate sample Web Services code for any table by selecting Setup > Tables > (Edit Table) > API > Download Sample.
The name of the table where the record is.
The identifier of the record to attach files to.
The name of the field to attach files to.
The position of the file to be removed.
The current number of files attached in the specified field.
EWSessionException - client not logged in or session has expired; client should re-login.
EWPermissionException - user used to create the session lacks sufficient privileges to read the record.
EWWrongDataException - client has supplied wrong data, for instance ID cannot be found.
EWOperationException - the operation has been blocked by and Agiloft function, for example a table-level lock.
EWIntegrityException - specified table cannot be found or its primary key cannot be identified.
EWUnexpectedException - an unexpected exception has occurred; the admin user should report this for investigation.