I have created a workflow to submit a registration to an external API . That API returns a receipt number that I wan to save in the record.
I have followed the instructions in the docs but saving is failing with the error:
The DELETE statement conflicted with the REFERENCE constraint "FK_UFRecordDataString_UFRecordFields_Key". The conflict occurred in database "XXXXXX", table "dbo.UFRecordDataString", column 'Key'.
The statement has been terminated.
My code is this:
using (RecordStorage store = new RecordStorage())
{
var receiptField = record.GetRecordFieldByAlias("receiptID");
receiptField.Values.Clear();
receiptField.Values.Add(receiptId);
store.UpdateRecord(record, e.Form);
}
I think that it is not really necessary to execute the UpdateRecord method in the workflow after altering a field on your record.
What I understand is, for the custom workflows that are set to run on "on send", the record is not stored in the DB yet, so you can just go on and change the fields as you like, and leave the saving or updating part to Umbraco forms.
This is the same reason why updating the record throws an error because the data is just not there.
But please make sure that you're running on at least Umbraco Forms 7.1.2, because there is a bug that is fixed in this version, which is related to the execution order of the workflows. (I'm mentioning this because, you might want to use the updated values that is passed on from the previous workflow in the line)
Unable to update record field in workflow
I have created a workflow to submit a registration to an external API . That API returns a receipt number that I wan to save in the record.
I have followed the instructions in the docs but saving is failing with the error:
The DELETE statement conflicted with the REFERENCE constraint "FK_UFRecordDataString_UFRecordFields_Key". The conflict occurred in database "XXXXXX", table "dbo.UFRecordDataString", column 'Key'. The statement has been terminated.
My code is this:
Any idea what's going on?
I'm running into the exact same issue here! Running Umbraco Forms 7.2.0. Did you manage to find a solution?
I found, that when you "Enable Post Moderation" saving works miraculously fine.
See also: https://issues.umbraco.org/issue/CON-1482
No, I haven't found a solution yet.
Hello,
To those who are having errors when updating the record, please take a look at this issue:
https://github.com/umbraco/Umbraco.Forms.Issues/issues/251
I think that it is not really necessary to execute the UpdateRecord method in the workflow after altering a field on your record.
What I understand is, for the custom workflows that are set to run on "on send", the record is not stored in the DB yet, so you can just go on and change the fields as you like, and leave the saving or updating part to Umbraco forms.
This is the same reason why updating the record throws an error because the data is just not there.
But please make sure that you're running on at least Umbraco Forms 7.1.2, because there is a bug that is fixed in this version, which is related to the execution order of the workflows. (I'm mentioning this because, you might want to use the updated values that is passed on from the previous workflow in the line)
https://our.umbraco.com/packages/developer-tools/umbraco-forms/
Note: You can only use UpdateRecord on workflows which run on "on approve" pipeline, since the record is already saved in the database.
is working on a reply...