Question

Photo of Brandon Gamache

0

Merge Templates Not Working

I'm having trouble getting Merge Templates to work. When I try to run one on a group I get a Page Not Found error. The URL is pointing to the file but it isn't able to download. (/App_Data/Files/Files/27554504-6e5a-43ab-b578-6889aecee83e_MergeTemplateOutput.docx?attachment=True). This was using the sample name tags template.


I also tried to create my own template based off of this and got a "FileMode or FileAccess value is not valid for the stream" I did change the file storage location of Merge Templates from the database to the File System, thinking this was the issue I changed it back to the DB and still got the same page error with the sample name tags. The demo site works so it isn't necessarily a Rock bug but an issue in my Rock. Any ideas what I may have done wrong? Or any ideas how I can go about fixing it?


Thanks

  • Photo of Nick Airdo

    0

    A few things to consider and check...

    • I would not recommend changing the Merge Template (Admin | General Settings | File Types) from Database to File-System because it won't just extract your existing templates from the DB and put them on the file system. If it's still trying to retrieve them from your file system (as you show above "/App_Data/Files...") you may want to restart Rock in the event that it is still cached. 
    • Does your Merge Template have the "Requires View Security?" checkbox checked?
    • What are the security settings on the "Merge Template" File Type?
    • What kind of Merge Template are you trying to use/merge into? HTML or Word?  (Both of these types fetch the stored template and then assemble it in memory first before streaming it out to the browser/client).
    • Is your "Internal Application Root" Global Attribute setting correctly pointing to your rock instance? (Admin | General Settings | Global Attributes)
    • Brandon Gamache

      Thanks Nick. I would like to use the FileSystem instead of the database if possible. I will change it back to database and restart Rock to see if that will make the samples work again (I'll have to test this at the end of the day).


      The stream issue I got was when I was adding a personal Merge Template but noticed I get the same issue when adding it as a Global Merge Template. To test the stream issue I downloaded one of the sample templates and I get the same issue when I add a new global template with the sample template as the file. To test it further, to make sure it wasn't a download issue from Rock since I switched the storage to file system, I downloaded one of the sample files from the demo server and uploaded it to a global merge template and got the stream issue.


      Requires View Security is on.


      Security settings are the default: All Users for View, Admins, Staff Workers, Staff like workers all have Edit access, and Administrate is Admins.


      The Template type is Word .docx


      The Internal Application Root is correctly set.

    • Brandon Gamache

      Found the main issue why it wasn't downloading a file when I switched it back to Database. I had Default file types set to File System and pointing to a Files folder. When I switched this back to Database it worked--as long as Merge Template File Types is set to database. Still uncertain why it wouldn't work when I had Merge Template File Type set to File System and Default File Type set to database. I'll try and look into this a little later.

    • Nick Airdo

      In its current form, the merge template system was not really designed to swap between different merge template file types without writing custom code. At a minimum, you'd have to create a new merge template (filesystem) File Type, then create a custom MergeTemplateDetail block that used your new custom Merge Template file type (instead of the core template Rock.SystemGuid.BinaryFiletype.MERGE_TEMPLATE).