I’m sure this is easy, but for the life of me I can’t figure it out, in my workflow I need to add a custom field which contains the transactionid, which is generated during the workflow execution.
Using the code below I am adding the field:
context.Record.RecordFields.Add(Guid.NewGuid(), new RecordField(new Field
{
Alias = "transactionId",
FieldTypeId = Guid.Parse("DA206CAE-1C52-434E-B21A-4A7C198AF877"),
Caption = "Transaction Id",
Id = Guid.NewGuid(),
Values = new List<object>
{
updateStartResponse?.TransactionReference ?? string.Empty
}
}));
However this is not being persisted to the database.
If I add the below line: _recordStorage.UpdateRecord(context.Record, context.Form);
I then get the following error:
The INSERT statement conflicted with the FOREIGN KEY constraint \"FK_UFRecordFields_UFRecords_Id\"