5

How can I add one more link in export action dropdown?

Export Excel in WFFM reports

I have patched 'export form data to excel' link with instead and it is working fine with custom processor but I want to add one more link/button for this custom export.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
  <sitecore>
    <pipelines>
      <exportToExcel>
        <processor patch:instead="processor[@type='Sitecore.WFFM.Services.Pipelines.ExportToExcel.ExportFormDataToExcel, Sitecore.WFFM.Services']" type="Website.Shared.Pipeline.CustomExportToExcel, Website.Shared" />
      </exportToExcel>
    </pipelines>    
  </sitecore>  
</configuration>
2
  1. Login to Sitecore backend
  2. Switch DB to core
  3. Insert new item under /sitecore/client/Applications/WFFM/Resources/Parameters/ActionControl Parameters/ActionColumn/
  4. Add new item with call of your JavaScript function. E.g.: javascript:app.doSomething()
  5. Open \sitecore\shell\client\Applications\WFFM\Pages\FormReport\FormReport.js file and add function doSomething to it. You can call any action from any controller with any parameters from your Javascript function.
  6. Create new pipeline and processor for it
  7. Execute new pipeline inside your action in controller by CorePipeline.Run("doSomething", formExportArgs);

Here is for example disassembled code of default endpoint(action in WFFM controller). You can use it as example:

        [ValidateHttpAntiForgeryToken]
        public ActionResult Export(Guid id, int format)
        {
            Assert.ArgumentNotNull(id, "id");
            Assert.ArgumentNotNull(format, "format");
            bool flag = format == 0;
            Item itemFromMasterDatabase = this.itemRepository.GetItemFromMasterDatabase(new ID(id));
            Assert.IsTrue(itemFromMasterDatabase != null, "Can't find the form.");
            Job job = Context.Job;
            if (job != null)
            {
                job.Status.LogInfo(DependenciesManager.ResourceManager.Localize("READING_DATA_FROM_DATABASE"));
            }
            IEnumerable<FormData> formData = this.FormsDataProvider.GetFormData(id);
            FormExportArgs formExportArgs = new FormExportArgs(this.itemRepository.CreateFormItem(itemFromMasterDatabase), new FormPacket(formData), this.webUtil.GetTempFileName(), flag ? "text/xml" : "application/vnd.ms-excel");
            formExportArgs.Parameters.Add("contextUser", Context.User.Name);
            CorePipeline.Run(flag ? "exportToXml" : "exportToExcel", formExportArgs);
            return base.Json(new
            {
                File = formExportArgs.FileName
            }, JsonRequestBehavior.AllowGet);
        }
| improve this answer | |
  • P.S. Let me know if you need more details on any of steps. – Anton May 3 '18 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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