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

EntitySave

Last update:
May 18, 2026

Description

Saves or updates data of the entity and all related entities to the database. ColdFusion automatically tries to find if a new record should be inserted or an existing record be updated for the given entity. If you set forceinsert=true, then ColdFusion tries to insert the entity as a new record.

Returns

Void

Category

Function Syntax

EntitySave(entity, [forceinsert])

See Also

History

ColdFusion 9: Added this function.

Parameters

Parameter
Description
entity
Name of the entity that must be saved in the database.
forceinsert
If true, then ColdFusion always tries to insert the entity as a new record.

Example

To save an entity:
<cfset employee = createObject("Employee")> 
 <cfset employee.setFirstName("Marcia")> 
 <cfset employee.setlastName("Em")> 
 <cfset EntitySave(employee)>
To update an entity:
<cfset employee = EntityLoad('employee', 100, true)> 
 <cfset employee.setLastName("Em")> 
 <cfset EntitySave(employee)>

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