Copied to clipboard

Flag this post as spam?

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


  • Joseph 12 posts 32 karma points
    Aug 10, 2011 @ 15:35
    Joseph
    0

    workflow delete record not working

    Can anyone explain how a record can be deleted in the entries?

    public class ContourDelete : WorkflowType
        {
            public ContourDelete()
            {
                this.Name = "Check spam";
                this.Id = new Guid("b3c5a019-5ed4-4a38-98aa-ecf2fc191648");
                //this.Id = new Guid();
                this.Description = "This will save an entry to the log";
            }

            public override List<Exception> ValidateSettings()
            {
                return new List<Exception>();
            }

            public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
            {
                RecordService rs = new RecordService(record);
                rs.Delete();
                rs.Dispose();
                return WorkflowExecutionStatus.Completed;
            }
        }

    1. I created a class that simply deletes a submitted record. When I created an id for the object in the constructor with

    this.id = new Guid();

    I will get.

     

    The INSERT statement conflicted with the FOREIGN KEY constraint "FK_UFRecordDataString_UFRecordFields". The conflict occurred in database "umbraco", table "dbo.UFRecordFields", column 'Key'.
    The statement has been terminated.

    SQL Server Exception

    Doing

    this.Id = new Guid("b3c5a019-5ed4-4a38-98aa-ecf2fc191648");

    can stop this happening. why is that?

    2. in the override method WorkflowExecutionStatus Execute

    a record should have been deleted when the form is submitted, but when I looked at the backoffice and database table, the record is still added. I am using a contour installed on a local machine without lisence.

    Is "rs.Delete()" a correct way to delete a record?

     

     

  • Joseph 12 posts 32 karma points
    Aug 11, 2011 @ 02:18
    Joseph
    0

    Have tried  

    var recordStorage = new RecordStorage();
    recordStorage.DeleteRecord(record);

    did not work either

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Aug 15, 2011 @ 12:52
    Tim
    0

    In answer to 1, the id for the workflow must be a STATIC Guid, i.e. you set it for the workflow once, and it doesn't ever change. If you have new Guid() then the workflow id chnages every time it loads, so it won't work properly. When I create new workflows etc I usually use one of the many online GUID generators to create a Guid for the workflow.

    If you use the static Guid, does the record get deleted, or is it still there?

  • Lasse Kofoed 49 posts 177 karma points
    Sep 05, 2012 @ 15:47
    Lasse Kofoed
    0

    I seam to have to same problem. In umbraco v 4.8.0 (Assembly version: 1.0.4583.15483) whit UmbracoContour 1.1.13.2

    [SqlException (0x80131904): The INSERT statement conflicted with the FOREIGN KEY constraint "FK_UFRecordDataString_UFRecordFields". The conflict occurred in database "umbraco_db", table "dbo.UFRecordFields", column 'Key'.

    Any solution to this ?

    public class ArrangementHandler : Umbraco.Forms.Core.WorkflowType   

    {

            public ArrangementHandler()        {

                this.Name = "Arrangement workflow";

                this.Id = new Guid("20584169-2351-4569-8c4c-cf76ddf97cda");

                this.Description = "Arrangement workflow til events";

            }

            public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)        {

      var deleteservice = new RecordService(record);

                    deleteservice.Delete();

                deleteservice.Dispose();

    }

       return WorkflowExecutionStatus.Completed;

            }

     

            public override System.Collections.Generic.ListValidateSettings()

            {

                Listexceptions = new List();

                return exceptions;

            }

Please Sign in or register to post replies

Write your reply to:

Draft