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

PutItem

Last update:
May 18, 2026

Description

The PutItem function creates an item, or replaces an old item with a new item.
For more information, see PutItem.

Category

History

ColdFusion (2021 release): Added this function.

Syntax

serviceHandle.putItem(requestParameters)

Parameters

See request parameters of PutItem.

Example

<cfscript> 
 cred = { 
    "credentialAlias" : "myalias", 
    "vendorName" : "AWS", 
    "region" : "us-east-2", 
    "secretAccessKey" : "xxxxx", 
    "accessKeyId" : "xxxx" 
  } 
  config = { 
    "serviceName" = "DYNAMODB" 
  } 
  dynamo = getCloudService(cred, config) 
  movieName="Movies008" 
 
  // Stage 1: create a table 
  tableStruct={ 
    TableName : "#movieName#", 
    KeySchema:[ 
        { AttributeName: "year", KeyType: "HASH"},  //Partition key 
        { AttributeName: "title", KeyType: "RANGE"}  //Sort key 
    ], 
    AttributeDefinitions:[ 
        { AttributeName: "year", AttributeType: "N" }, 
        { AttributeName: "title", AttributeType: "S" } 
    ], 
    ProvisionedThroughput:{ 
        ReadCapacityUnits: 10, 
        WriteCapacityUnits: 10 
    } 
 } 
 dynamo.createTable(tableStruct) 
 sleep(3000) 
 
 // Stage 2: insert an item into the table 
 
 putItemStruct={ 
    "TableName":"#movieName#", 
    "Item":{ 
      "year": {"N": 2019}, 
      "title": {"S": "Golden"} 
    }, 
    "ReturnValues": "NONE" 
 } 
 
 try{ 
    putItemResponse=dynamo.putItem(putItemStruct,{"hasType": true}) 
    writeOutput("Item inserted successfully in the table.") 
    writeDump(putItemResponse) 
 } 
 catch (any e){ 
    writeDump(e) 
 } 
</cfscript>

Output

Figure: PutItem output
PutItem 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