Copied to clipboard

Flag this post as spam?

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


  • Paul de Quant 403 posts 1520 karma points
    Jun 29, 2017 @ 09:05
    Paul de Quant
    0

    Update Field Value in Workflow

    Hi,

    I need to manipulate the data being submitted via an Umbraco Form. So i've created a custom workflow to do this. The problem I have is that even though I can change the field it's not being saved in the database. Can anyone see what's wrong with this code:-

            public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
        {
    
            try
            {
                foreach (RecordField rf in record.RecordFields.Values)
                {
                    var fieldValue = rf.ValuesAsString();
    
                    rf.Values[0] = EncryptData.Encrypt(rf.ValuesAsString(), "Crypto-key!"); // Crypto-key! = the encryption Key to use, change this!
    
                    fieldValue = rf.ValuesAsString();
                    LogHelper.Info(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "OUTPUT: " + rf.Values[0]);
    
                }
    
                //If we altered a field, we can save it using the record storage
                RecordStorage store = new RecordStorage();
                store.UpdateRecord(record, e.Form);
                store.Dispose();
    
                LogHelper.Info(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "Record saved with Encryption");
    
                return WorkflowExecutionStatus.Completed;
            }
            catch (Exception ex)
            {
                LogHelper.Warn(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, ex.Message);
                return WorkflowExecutionStatus.Failed;
            }
    
        }
    

    The log file doesn't seem to show any errors, so I can only assume I'm missing some key step.

    Many thanks

    Paul

Please Sign in or register to post replies

Write your reply to:

Draft