Copied to clipboard

Flag this post as spam?

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


  • Matt Barlow | jacker.io 164 posts 740 karma points c-trib
    Apr 14, 2018 @ 19:54
    Matt Barlow | jacker.io
    0

    Upload files not being attached when choosing the Send Email with Template (Razor) workflow

    I am using the following versions: Umbraco 7.10.2 Umbraco Forms 7.0.1 Perplex Forms 1.8.3

    I did a clean install of all three, and am using the Perplex File Upload to select files, on a simple form.

    Then I create a workflow item - selecting to attach uploaded files - Send Email with Template (Razor). enter image description here

    enter image description here

    The email sends but the attachment isn't added, when I switch to using the native File Upload then it works.

    I have the smtp server on my local machine so I can see it's not being attached.

    Any ideas how I can fix this?

    Thanks in advance.

  • Daniël Knippers 153 posts 1116 karma points MVP 2x c-trib
    Apr 16, 2018 @ 07:01
    Daniël Knippers
    100

    Hi Matt,

    This is a built-in Umbraco workflow, it might only work with Umbraco's File Upload. Unfortunately, Umbraco Forms is not open source so I cannot look at their source. As far as I can tell there is no way for us to specify whether our Field Type (like File Upload / Image Upload) generates attachments so it can be picked up by the workflow. The workflow might just match on field type alias and/or unique field type id and is not checking for our field types.

    Perhaps you can ask Umbraco if their workflow works with custom field types.

    -- Daniël

  • Matt Barlow | jacker.io 164 posts 740 karma points c-trib
    Apr 16, 2018 @ 18:37
    Matt Barlow | jacker.io
    0

    Hey Daniel,

    Thanks for the quick response. Makes sense, it does work when using the non-html workflow as well, so hopefully this wouldn't be a big change to Umbraco Forms if they could implement it.

    Thanks,

    -M

  • Jesse Andrews 191 posts 716 karma points c-trib
    May 13, 2022 @ 18:31
    Jesse Andrews
    1

    For anyone that runs into this issue, there is a workaround for this problem. It requires a custom workflow unfortunately, but it fairly straightforward and can be seen below (this implementation is for umbraco 8).

    public class CustomSendRazorEmail : SendRazorEmail {
    
        public CustomSendRazorEmail (IHttpContextAccessor httpContextAccessor, IFieldTypeStorage fieldTypeStorage, IFormStorage formStorage, IUmbracoContextAccessor umbracoContextAccessor, IPageService pageService, IWorkflowEmailService workflowEmailService) : base(httpContextAccessor, fieldTypeStorage, formStorage, umbracoContextAccessor, pageService, workflowEmailService) {
            Id = new Guid("{unique id}");
            Name = "Custom Send Razor Email";
            Icon = "icon-message";
            Group = "Services";
        }
    
        public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e) {
            var uploadFieldId = new Guid("{id of custom upload field}");
            var uploadFields = record.RecordFields.Where(x => x.Value.Field.FieldTypeId == uploadFieldId);
            //this is a hack to get umbraco forms to attach files from a custom upload field
            foreach (var uploadField in uploadFields) {
                uploadField.Value.Field.FieldTypeId = new Guid(Constants.FieldTypes.Upload);
            }
            var result = base.Execute(record, e);
            foreach (var uploadField in uploadFields) {
                uploadField.Value.Field.FieldTypeId = uploadFieldId;
            }
            return result;
        }
    }
    

    Umbraco forms only attaches files from the built in upload field, so the hack involves assigning that id to the custom upload fields. This will get the base class to attach those files when it's executed. It then reverts those id changes to avoid causing problems in future workflows. This is definitely a hack, but it will work until we get a proper fix for this problem (issue filed in bug tracker here).

Please Sign in or register to post replies

Write your reply to:

Draft