Copied to clipboard

Flag this post as spam?

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


  • Mario Lopez 168 posts 952 karma points MVP 3x c-trib
    Oct 11, 2019 @ 00:51
    Mario Lopez
    0

    Unable to update record field in workflow

    I have created a workflow to submit a registration to an external API . That API returns a receipt number that I wan to save in the record.

    I have followed the instructions in the docs but saving is failing with the error:

    The DELETE statement conflicted with the REFERENCE constraint "FK_UFRecordDataString_UFRecordFields_Key". The conflict occurred in database "XXXXXX", table "dbo.UFRecordDataString", column 'Key'. The statement has been terminated.

    My code is this:

    using (RecordStorage store = new RecordStorage())
    {
        var receiptField = record.GetRecordFieldByAlias("receiptID");
    
        receiptField.Values.Clear();
        receiptField.Values.Add(receiptId);
    
        store.UpdateRecord(record, e.Form);
    }
    

    Any idea what's going on?

  • marcelh 171 posts 471 karma points
    Oct 16, 2019 @ 13:27
    marcelh
    0

    I'm running into the exact same issue here! Running Umbraco Forms 7.2.0. Did you manage to find a solution?

    I found, that when you "Enable Post Moderation" saving works miraculously fine.

    See also: https://issues.umbraco.org/issue/CON-1482

  • Mario Lopez 168 posts 952 karma points MVP 3x c-trib
    Oct 16, 2019 @ 22:48
    Mario Lopez
    0

    No, I haven't found a solution yet.

  • Batuhan Akçay 3 posts 93 karma points
    Jan 31, 2020 @ 11:24
    Batuhan Akçay
    0

    Hello,

    To those who are having errors when updating the record, please take a look at this issue:

    https://github.com/umbraco/Umbraco.Forms.Issues/issues/251

    I think that it is not really necessary to execute the UpdateRecord method in the workflow after altering a field on your record.

    What I understand is, for the custom workflows that are set to run on "on send", the record is not stored in the DB yet, so you can just go on and change the fields as you like, and leave the saving or updating part to Umbraco forms.

    This is the same reason why updating the record throws an error because the data is just not there.

    But please make sure that you're running on at least Umbraco Forms 7.1.2, because there is a bug that is fixed in this version, which is related to the execution order of the workflows. (I'm mentioning this because, you might want to use the updated values that is passed on from the previous workflow in the line)

    enter image description here

    https://our.umbraco.com/packages/developer-tools/umbraco-forms/

    Note: You can only use UpdateRecord on workflows which run on "on approve" pipeline, since the record is already saved in the database.

Please Sign in or register to post replies

Write your reply to:

Draft