Whatever message this page gives is out now! Go check it out!

DeleteItem

Last update:
May 18, 2026

Description

This function delete an item in a table via the primary key. You can perform a conditional delete operation that deletes the item if it exists, or if it matches the value of an attribute.
For more information, see DeleteItem.

Category

History

ColdFusion (2021 release): Added this function.

Syntax

serviceHandle.deleteItem(requestParameters)

Parameters

See request parameters of DeleteItem.

Example

<cfscript> 
  cred = { 
    "credentialAlias" : "myalias", 
    "vendorName" : "AWS", 
    "region" : "us-east-2", 
    "secretAccessKey" : "xxxxx", 
    "accessKeyId" : "xxxx" 
  } 
  config = { 
    "serviceName" = "DYNAMODB" 
  } 
  dynamo = getCloudService(cred, config) 
  tableName="YearlyProductCatalog" 
  // items to delete 
  id=550 
  title="My Books Title" 
  // delete the item in the table 
  deleteItemStruct={ 
    "TableName":"#tableName#", 
    "Key":{ 
      "id":{"N":"#id#"}, 
      "title":{"S":"#title#"} 
    }, 
    "ReturnValues": "ALL_OLD" 
  } 
  try{ 
    deleteItemResponse=dynamo.deleteItem(deleteItemStruct,{"hasType": true}) 
    writeOutput("Item deleted successfully") 
    writeDump(deleteItemResponse) 
  } 
  catch(any e){ 
    writeDump(e) 
  } 
</cfscript>

Output

Figure: DeleteItem output
DeleteItem output

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page