SaveChanges()

Saves changes made to the current record to the database.

This method refreshes the RecordObject to point back to the beginning of the selected record set. You can't use it on a RecordObject where the same RecordObject is used in the condition in a while loop. For a workaround, see example 2 below.

Examples

var Comp;
var block;
Comp = CRM.CreateRecord('company');
Comp.item('comp_Name') = '4D Communications International';
Comp.SaveChanges();
block = CRM.GetBlock("companygrid");
CRM.AddContent(block.execute(''));
Response.Write(CRM.GetPage());

Adds and saves a new record to the company table and displays in a list.

var companies;
var company;
companies = CRM.FindRecord("company","comp_name like 'Gate%'");
while (!companies.eof)
{
Response.Write(companies('comp_name')+'') ;
Response.Flush();
company = CRM.FindRecord('company', 'comp_companyid=' + companies.comp_companyid);
company.comp_type = 'Member';
company.SaveChanges();
companies.NextRecord();
}
Response.Write('End');

Demonstrates a workaround for using the SaveChanges() method in a loop.