3

I'm having trouble reading the value from a Web Forms For Marketeers Upload File field within my Custom Save Action. As I understand it I should just be able to do this in the Save action Execute method like so (note: my field name is 'Upload' on the form):

public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null, params object[] data)
{           
    var fileUpload = adaptedFields.GetEntryByName("Upload");
}

I'm expecting the value to be an item id to the file uploaded but it is null.

I've looked at the out of the box ProcessMessage pipeline and the AddAttachments() method does something similar as it loops through each field in the form (AdaptedControlResult) and then grabs field.Value.

Jonathan Robins also does something similar in his blog post here: https://jonathanrobbins.co.uk/2015/02/18/sitecore-web-forms-for-marketers-send-email-with-attachment-save-action/

So it looks like what I'm doing is right but I've no idea why the value is null and how to resolve this. Any help would be appreciated.

7
  • what version of wffm are you using? Apr 25, 2017 at 10:02
  • Sitecore 8.1 so I think the version number of WFFM matches up with this but I'll double check now Apr 25, 2017 at 10:09
  • do you have CM and CD? Apr 25, 2017 at 10:09
  • Yes we do, but this is just testing on my local machine which has CD and CA on it Apr 25, 2017 at 10:10
  • @SitecoreClimber It's WFFM.8.1.Update-2.1.0.1. Is there is a known bug with this release? Apr 25, 2017 at 10:44

1 Answer 1

1

In the end this turned out to be because we had the "WFM.IsRemoteActions" value on CD set to "true".

The WFFM Install Guide says to set this value to "true" on the CD servers: https://dev.sitecore.net/~/media/90C33269880C4E259D47CCA5A71EAA9A.ashx

However according to Sitecore Support:

This setting indicates that Wffm should not execute actions on this server, but write them to EventQueue of core database only. Afterwards, a server which shares this core database and has the hook and event handler for wffm:action:remote can process these actions. Generally, removing (or setting to false) this setting makes wffm to work in the simplest way on CD.

With this setting set to true files will be saved to the CM server only and not CD so this explains why the value of the PostedFile field was empty on CD.

Since we are using CMS Only Mode and don't have any analytics save actions tied to our forms then setting this to "false" isn't an issue for us.

The easiest way to do this is via a patch file like so:

<?xml version="1.0" encoding="utf-8"?>

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:x="http://www.sitecore.net/xmlconfig/">
    <sitecore>
        <settings>
            <setting name="WFM.IsRemoteActions" value="false" />
        </settings>
    </sitecore>
</configuration>

Hopefully this helps others who come across this problem as it was a painful one to diagnose.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.