Unable to update form record - UpdateRecord(formRecord, form)
I have API method to update or insert the form record based on whether the UniqueId is provided or not. But I got the error when try to update the existing form record. Why does the Umbraco.Forms.Data.Storag.RecordStorage.UpdateRecord() perform the Insert? Any help will be greatly appreciated!
PJ
Error:
{"The INSERT statement conflicted with the FOREIGN KEY constraint \"FKUFRecordFieldsUFRecords_Id\". The conflict occurred in database \"myUmbracoDB\", table \"dbo.UFRecords\", column 'Id'.\r\nThe statement has been terminated."}
Sample Code:
Guid recordId;
bool isValidId = Guid.TryParse(rec.RecordId, out recordId);
var formRecord = new Record()
{
UniqueId = isValidId ? recordId : Guid.NewGuid(),
UmbracoPageId = docuemnt.Id,
Created = DateTime.Now,
Form = form.Id,
State = FormState.Opened,
RecordFields = fieldDictionary
};
formRecord.RecordData = formRecord.GenerateRecordDataAsJson();
using (var storage = new RecordStorage())
{
var record = isValidId ? storage.UpdateRecord(formRecord, form) : storage.InsertRecord(formRecord, form);
}
The reason is the table UFRecordFields has been altered and the Record became the foreign key of UFRecords.Id. Looks like the UpdateRecord() function insert the records into UFRecordFields.
Unable to update form record - UpdateRecord(formRecord, form)
I have API method to update or insert the form record based on whether the UniqueId is provided or not. But I got the error when try to update the existing form record. Why does the Umbraco.Forms.Data.Storag.RecordStorage.UpdateRecord() perform the Insert? Any help will be greatly appreciated!
PJ
Error: {"The INSERT statement conflicted with the FOREIGN KEY constraint \"FKUFRecordFieldsUFRecords_Id\". The conflict occurred in database \"myUmbracoDB\", table \"dbo.UFRecords\", column 'Id'.\r\nThe statement has been terminated."}
Sample Code:
The reason is the table UFRecordFields has been altered and the Record became the foreign key of UFRecords.Id. Looks like the UpdateRecord() function insert the records into UFRecordFields.
is working on a reply...