So I've got a contour workflow that fires when a form has been submitted so sanitize the data being submitted. The issue is that updated values aren't being saved into the database, can anyone point out where I'm going wrong?
public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
{
var controlsToValidate = ControlNames.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
bool containsXss = false;
if (controlsToValidate.Length > 0)
{
foreach (string controlName in controlsToValidate)
{
var recordField = record.RecordFields.Values.FirstOrDefault(f => f.Field.Caption == controlName);
if (recordField != null)
{
var values = recordField.Values;
for (int i = 0; i < values.Count; i++)
{
// sanitize
}
recordField.Values = values;
}
}
}
using (RecordService rs = new RecordService(record))
{
if (containsXss)
{
if (string.Equals(RecordAction.Trim(), "Delete Record", StringComparison.OrdinalIgnoreCase))
{
rs.Delete();
}
else if (string.Equals(RecordAction.Trim(), "Approve Record", StringComparison.OrdinalIgnoreCase))
{
using (var store = new RecordStorage())
{
store.UpdateRecord(record, e.Form);
store.UpdateRecordXml(record, e.Form);
}
rs.Approve();
}
}
else
{
rs.Approve();
}
}
return WorkflowExecutionStatus.Completed;
}
Update fields on submission
Hi,
So I've got a contour workflow that fires when a form has been submitted so sanitize the data being submitted. The issue is that updated values aren't being saved into the database, can anyone point out where I'm going wrong?
Comment author was deleted
Think you'll have to add that workflow on the approved state or the data will get overwritten.
Can you give that a try?
#h5yr
That fixed it, although as a note to other people, remove the rs.Approve() calls as this will cause an endless loop ;)
is working on a reply...