Copied to clipboard

Flag this post as spam?

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

  • Emil Lindgren 28 posts 190 karma points
    May 16, 2019 @ 08:54
    Emil Lindgren

    Umbraco Forms - Custom Workflow

    Hello, So im trying to create a workflow that after submit it will download a file that will be chosen in the workflow.

    But im having kinda trouble with the execution of the WorkflowExecutionStatus Execute() method.

    even if i take the one example umbraco has on this page:

    it will not work.

    this is the code i have done so far:

      public class Workflow_file_download : WorkflowType
          [Umbraco.Forms.Core.Attributes.Setting("Whitepaper", description = 
         "File to be downloaded", view = "File")]
          public string FileChoose { get; set; }
          public Workflow_file_download()
             //Id = new Guid();
             Name = "DownloadFile";
             Description = "This workflow lets you download a file";
             //Group = "Services";
          public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
             Log.Add(LogTypes.Debug, int.Parse(FileChoose), "record submitted from: " + record.IP);
             //var helper = new UmbracoHelper(UmbracoContext.Current);
             //var file = helper.AssignedContentItem.GetPropertyValue<string>("whitepaperFile");
             if (!string.IsNullOrEmpty(FileChoose))
                var filename = HostingEnvironment.MapPath("~" + FileChoose);
                if (!string.IsNullOrEmpty(filename))
                      var filepath = new FileInfo(filename);
                      var response = HttpContext.Current.Response;
                      return WorkflowExecutionStatus.Completed;
                   catch (Exception ex)
                      LogHelper.Error<Workflow_file_download>("Downloading file failed - ", ex);
                      return WorkflowExecutionStatus.Failed;
             return WorkflowExecutionStatus.Failed;
          public override List<Exception> ValidateSettings()
             List<Exception> exceptionList = new List<Exception>();
             //int docId = 0;
             //if (!int.TryParse(FileChoose, out docId))
             //   exceptionList.Add(new Exception("Document ins not valid"));
             if (string.IsNullOrEmpty(FileChoose))
                exceptionList.Add(new Exception("FileChoose has not been choosen "));
             return exceptionList;

    Any suggestions or tips?

    Kind regards / Emil

  • Yakov Lebski 538 posts 2100 karma points
    Jun 19, 2019 @ 21:23
    Yakov Lebski

    You must define static and unique ID for workflow in the constructor

     public TestWorkflow()
        this.Id = new Guid("ccbeb0d5-adaa-4729-8b4c-4bb439dc0202");
        this.Name = "TestWorkflow";
        this.Description = "This workflow is just for testing";
        this.Icon = "icon-chat-active";
        this.Group = "Services";
Please Sign in or register to post replies

Write your reply to: