Removes the attached file specified by a position in the named field of the specified table record.
int n = ew.EWRemoveAttached(String sessionId, String tableName, long id, String fieldName, int position); |
Use the EWRemoveAttached call to remove an attached file from a File or Image field in a record in the table.
When removing attached files, consider the following rules and guidelines:
Removing files from records involves the following basic steps:
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:
You can generate sample Web Services code for any table by selecting Setup > Tables > (Edit Table) > API > Download Sample.
public int remove() throws Exception { EWServiceAPI binding = new EWServiceAPIServiceLocator().getDemo(); try { String sessionId = binding.EWLogin("MyKB", "A", "password", "en"); WSCase wsCase = (WSCase) binding.EWRead(sessionId, "case", 456); String[] fileNames = wsCase.getAdditional_Files(); int n = 0; if (fileNames!=null) { for (int i = 0; i < files.length; i++) { if ("B.txt".equals(fileNames[i])) { n = binding.EWRemoveAttached("case", 456, "additional_files", i); } } } return n; } finally { binding.EWLogout(sessionId); } } |
Name | Type | Description |
---|---|---|
sessionId | String | Session token |
tableName | String | The name of the table where the record is. |
id | long | The identifier of the record to attach files to. |
fieldName | String | The name of the field to attach files to. |
position | int | 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 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.
Related articles |