Copied to clipboard

Flag this post as spam?

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


  • Greg Fyans 140 posts 342 karma points
    Jan 16, 2014 @ 13:14
    Greg Fyans
    0

    Issue programmatically updating record fields

    Hi,

    I'm trying to update a field value on a partially submitted form, using a custom workflow in Contour 3.0.18. The workflow is set to execute when the form has been PartiallySubmitted.

    This is my code:

    public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
    {
        record.GetRecordField(fieldId).Values.Clear();
        record.GetRecordField(fieldId).Values.Add("123456");
    
        RecordStorage rs = new RecordStorage();
    
        rs.UpdateRecord(record, e.Form);
        rs.UpdateRecordXml(record, e.Form);
    
        rs.Dispose();
    }
    

    The record field type I'm trying to update is of HiddenField.

    It is updating the value (I've attached a debugger and can see the record field value is being modified) but it doesn't persist it to the database.

    I've compared this code with an example on Tim's blog, and apart from the fact that he's creating a new instance of a Form and I'm using the instance passed in the Event Args, it's the same. However, I've also tried creating a new instance of a form and that doesn't work either.

    Any ideas?

    Greg.

  • Comment author was deleted

    Jan 16, 2014 @ 13:19

    Any reason you are adding this to the partially submitted? generally when updating record values I recommend to do this on the approved stage (so final stage) to avoid conflicts

  • Greg Fyans 140 posts 342 karma points
    Jan 16, 2014 @ 13:22
    Greg Fyans
    0

    It's part of a multi-step application form that has resume functionality. I need to add this after the very first step is submitted so the applicant can abandon the form and then resume later.

    Greg.

  • Comment author was deleted

    Jan 16, 2014 @ 13:27

    Ok will do a test run and see why the value is being overwritten, more details later today

  • Greg Fyans 140 posts 342 karma points
    Jan 16, 2014 @ 13:28
    Greg Fyans
    0

    Cool. Thanks for looking into it.

  • Comment author was deleted

    Jan 16, 2014 @ 16:18

    Looking at the code... manipulating the record should do the trick, trying to debug now, hopefully I'll have a solution for you today

  • Comment author was deleted

    Jan 16, 2014 @ 16:46

    Ok seems it's due to the fact that the record is being passed as a value and not as a reference, so the changes will be overwritten, looking into a fix

  • Greg Fyans 140 posts 342 karma points
    Jan 16, 2014 @ 17:38
    Greg Fyans
    0

    Top man, look forward to it. Basically got this whole implementation working, just need this and I'm done :)

  • Comment author was deleted

    Jan 16, 2014 @ 17:41

    Ah the pressure :p hope to get a solution for you tomorrow, stay tuned!

  • Comment author was deleted

    Jan 17, 2014 @ 09:55

    Been trying different things but always end up with breaking changes so can't introduce that in Contour at this point :( what I would suggest is that you just create an extra table and store your extra record details in that one (linking it to the record id)

    Would that work as a workaround for you?

  • Greg Fyans 140 posts 342 karma points
    Jan 17, 2014 @ 11:23
    Greg Fyans
    0

    Ah, OK, I'll look into a workaround. Thanks for trying.

    Greg.

  • Bo Jacobsen 605 posts 2403 karma points
    Feb 12, 2016 @ 09:27
    Bo Jacobsen
    0

    I got the same issue. I want to update the record with the currentUmbracoPage informations on submit.

    But it won't update the record and if i get the record to udate, it crashes the server.

    Dont update this way as i though it would.

    public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
        {
            record.GetRecordField("Aktivitet").Values.Clear();
            record.GetRecordField("Aktivitet").Values.Add("1, aktivitet");
    
            var fs = new FormStorage();
            var form = fs.GetForm(record.Form);
            var rs = new RecordStorage();
            rs.UpdateRecord(record, form);
            rs.UpdateRecordXml(record, form);
    
            fs.Dispose();
            rs.Dispose();
    
            return WorkflowExecutionStatus.Completed;
        }
    

    Update the record, but crashes the server

    public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
        {
            record.GetRecordField("Aktivitet").Values.Clear();
            record.GetRecordField("Aktivitet").Values.Add("1, aktivitet");
    
            RecordService.Instance.Submit(record, e.Form);
    
            return WorkflowExecutionStatus.Completed;
        }
    

    Updates the record field if not set to manuelly approve submitted records. If i want to manuelly approve the records, it wont save it to the fields, but it sends the field data that is not set with the currect value in a mail.

    public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
        {
    
            record.GetRecordField("Aktivitet").Values[0] = "1, aktivitet";
            return WorkflowExecutionStatus.Completed;
        }
    

    I will make a new post about this. its urgent for me..

  • Romeo Cadaoas 33 posts 110 karma points
    May 14, 2017 @ 12:46
    Romeo Cadaoas
    0

    HI Bo Jacobsen, I'm having the same issues. Where you able to resolve this?

  • Romeo Cadaoas 33 posts 110 karma points
    May 15, 2017 @ 07:22
    Romeo Cadaoas
    0

    This works for me

    record.GetRecordField("Aktivitet").Values.Clear();
    record.GetRecordField("Aktivitet").Values = new List<object> { newValue};
    
    RecordService.Instance.Submit(record, e.Form);
    

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft