Copied to clipboard

Flag this post as spam?

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


  • Derek Staszak 15 posts 106 karma points
    Mar 28, 2017 @ 18:31
    Derek Staszak
    0

    Update hidden field value from workflow

    Hi,

    I am currently using umbraco forms for a quiz on my website. I am currently using a workflow to score the quiz and send send out different emails based on the score. I am trying to use a hidden field I can update in the workflow to save the score but I have not had any success getting the record to change.

    This is the code block I am using to try and update the hidden field.

            // UPDATE RECORDS TO INCLUDE SCORE
            foreach (RecordField recordField in record.RecordFields.Values)
            {
                if (recordField.Field.Caption == "Score")
                {
                recordField.Values.Clear();
                recordField.Values = new List<object> { "something" };
                }
            }
    
            Umbraco.Forms.Data.Storage.RecordStorage store = new RecordStorage();
            store.UpdateRecord(record, e.Form);
            store.Dispose();
    

    I would greatly appreciate any assistance I can get.

    Thanks,

  • MrFlo 159 posts 403 karma points
    Oct 31, 2017 @ 14:22
    MrFlo
    0

    Hi,

    I'm struggling to do the same! Did you find a solution to do this ? Would be nice to share it here? The best would be to create the field automatically if it doesn't exist.

    I think there is a lack of documentation for all those Forms and this is suppose to be a premium package. All docs found are from Countours webforms which was perfectly supported by Tim Geysens. This is not the first post I am seeing unanswered about Forms.

    Florent

  • Chris Dixon 12 posts 55 karma points
    Jan 31, 2018 @ 19:10
    Chris Dixon
    1

    A bit late for you guys but one for posterity... based on answers for similar topics I think my changes were being overwritten when the form gets Approved automatically. So tick Enable Post Moderation, which leaves the form in a Submitted state rather than Approved, and then Approve it in code after the UpdateRecord.

    // set field value
    recordField.Values.Clear();
    recordField.Values.Add(fieldValue);
    
    // save record
    RecordStorage recordStorage = new RecordStorage();
    recordStorage.UpdateRecord(record, form);
    recordStorage.Dispose();
    
    // set to Approved
    var recordService = new Umbraco.Forms.Web.Services.RecordService();
    recordService.Approve(record, form);
    
Please Sign in or register to post replies

Write your reply to:

Draft