The SharePoint object model provides a supported way of updating a record without unlocking it. There's a guide here that describes some of the relevant information. I was able to get a working example (excuse some of the 'basic' naming) in an ItemUpdated event receiver.
using (SPSite site = new SPSite(properties.SiteId))
using (SPWeb web2 = site.OpenWeb(properties.Web.ID))
SPListItem item = web2.Lists.GetList(properties.List.ID, false).GetItemById(properties.ListItemId);
Records.BypassLocks(item, delegate(SPListItem newItem)
newItem["Title"] = "Hello from code";
newItem.Audit.WriteAuditEvent(SPAuditEventType.Custom, SPAuditEventSource.ObjectModel.ToString(), "<Data>Audit text</Data>");
As usual with
SPSecurity.RunWithElevatedPrivileges, you must create new SPSite and SPWeb objects, as well as a new SPListItem object otherwise you end up with the error
Attempted to perform an unauthorized operation.