JavaScript method: SCFile.deleteAttachment( attachID )

This method deletes a specific attachment associated with the current file record.

Values passed to deleteAttachment() will normally be ones obtained from a previous insertAttachment(), updateAttachment(), or getAttachments() operation.

Before calling deleteAttachment, you must establish a current record using one of the positioning methods, such as doSelect(), getNext(), etc.

Syntax

SCFile_object.deleteAttachment( attachID );

Arguments

deleteAttachment() takes one argument, which is a string containing an attachment ID of the cid:xxxxx form.

Return values

If successful, deleteAttachment() returns RC_SUCCESS. Otherwise. it returns an error return code. For example, it returns RC_NO_MORE if the attachment was not found.

Example

This example does the following:

  • Selects one record from the probsummary file
  • Deletes one attachment associated with the current record

This example requires the following sample data:

  • Record number IM10001 in the probsummary table

function createTestAttachment()
{
  var attachmentObj = new Attachment();

  attachmentObj.type  = "text/plain";
  attachmentObj.name  = "MyAttachment.txt";
  attachmentObj.value = "My text attachment";

  var f = new SCFile( 'probsummary' );
  
  var rc = f.doSelect( 'number = "IM10001"' );
  
  var attachmentID = f.insertAttachment( attachmentObj );  

  return attachmentID;
}

var attachmentID = createTestAttachment();

var f = new SCFile( 'probsummary' );

var rc = f.doSelect( 'number = "IM10001"' );

var rc = f.deleteAttachment( attachmentID );