Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • elspiko 133 posts 302 karma points
    Oct 28, 2011 @ 11:54
    elspiko
    0

    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?

     

    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;
    }
    
  • Comment author was deleted

    Oct 28, 2011 @ 11:57

    Think you'll have to add that workflow on the approved state or the data will get overwritten.

    Can you give that a try?

  • elspiko 133 posts 302 karma points
    Oct 28, 2011 @ 14:10
    elspiko
    0

    #h5yr

    That fixed it, although as a note to other people, remove the rs.Approve() calls as this will cause an endless loop ;)

Please Sign in or register to post replies

Write your reply to:

Draft