MODX Community

FormIt Integration Options: Make Form Submissions Easily Accessible to Client Only

Would like method for client to access form submissions in the FormIt database.
Brainstorming here, but looking for optimum solution.

  1. extra or code for also submitting or porting form submissions to google doc.
  2. provide client with manager login to allow access ONLY to the FormIt database.
  3. create a password protected webpage that displays the FormIt submission data.

Big thanks ahead of time for any feedback or tips.

  • List item
1 Like

Formit comes out of the box with a custom manager page that lists form submissions (if you’re saving forms, at least, which is done with the FormItSaveForm hook) - perhaps that suits your needs?

1 Like

Hey Mark:

So happy to receive your response and hope you are doing well. Long time no chat.

I have the form saving to a database, and provide the client with a CSV upon request. I am willing to provide them a user and password, but do not want them to have access to any other aspect of the site or manager.

1 Like

Are they currently web users or users with another level?

Seems to me rather than give them access to the formit manager, can’t you just output the csv file list for that user on a page?

Not sure what your real need is here, you seem to be getting into issues with groups and group permissions. That gets a bit time consuming and there may be easier ways to achieve the same goal.

Thank you for this feedback. Yes… I think groups + permission is too much. Outputting to a page, and then perhaps password protecting that page would be ideal. So… are there examples of outputting all of the submissions to a page?

1 Like

These are ‘web’ users, in other words just regular front end users?

Don’t know how ideal this solution would be for you but you can try…

  1. Create a new resource with content/type TSV and richtext false
    (I prefer TSV over CSV as escaping commas can get messy). (You’ll also need to create a new content type under Content > Content Types – file ext .tsv and mime: text/tsv).

  2. Using Rowboat extra add this to your resource document

    [[!Rowboat?
    &table=`modx_formit_forms`
    &tpl=`formit_tsv`
    &limit=`0`
    &sortBy=`id`
    ]]

Make sure to publish the resource… (I forgot and took me a solid 5 min to figure out why it wasn’t pooling data… :face_with_raised_eyebrow:).

  1. Create a chunk called formit_tsv and add the following:
    [[+form]] [[+values]] [[+ip]] [[+date]]

Make sure that those placeholders are actually spaced by tabs (open a code editor and find/ replace \s with \t should work). Also, make sure that you have a new line after this code (so 2 lines with second one empty).

Now when you view the resource it should download a TSV file with your forms… do note that if your forms are encrypted you’ll only get a hashed string in the [[+values]] field. I highly recommend you encrypt your forms to conform with GDPR (and its good security practice). I personally haven’t figured out how to decrypt the data… i’ll get there someday :smiley: This is just an example after all.

  1. Create a google sheet and add =IMPORTDATA("https:///yourdomain.com/tsv-resource.tsv")
    This will add that data directly to the Google Sheet, you can then share that with your client.

I’ve tried the above and it seems to be working alright… the issue is my forms are encrypted so I’m just getting the hashed values. If you figure out how to decrypt them let me know :smiley:

Best of luck

1 Like

This looks good and great effort, but does it limit the output to the user’s own forms and no other forms? That might not be needed but I thought it was…

Let’s get some OP feedback

Ahh. Good point. You could always write a JSON where statement for the &where param. Something like {"name":"client_form_name"} should work.

(Not tested)

1 Like

Thank you for this very helpful feedback. The person I am doing this for did ask for a google spreadsheet or something similar. I think RowBoat is the solution I was searching for. I really appreciate the recommendations and tips for implementing. I was working with FormItLoadSavedForm last night, but was not able to get it to output the data onto a resource. I’ll give RowBoat a try and post results later this morning.

2 Likes

Pls let us know if there are multiple users of your site that you want to give access to, or just one client of the site? If its just one client on the site then you won’t need to worry about limiting the output to only that users’ data

@inside-creative really excellent and detailed solution!

Getting close with this one. Safari on Mac now prompts for your approval to download a document. In the case of this TSV… there is not prompt, so no file was downloading. Attempted using Chrome… and voila! the TSV file downloaded. File was empty… but at least it’s downloading.

Best I can tell? Perhaps the table is incorrect. modx_formit_forms should be all forms correct? I only have one form, but perhaps I need to specify the form by name?

I can get a download, but no content.

Double check the error log. I suspect it could either be that the snippet call didn’t copy/ paste properly from the forums. Or that there’s an issue with the extra. Double check it’s installed :).

The table modx_formit_froms holds all forms saved by the formitSaveForm hook. But double check your DB to be sure - the error will tell you if it can’t find the table with that name.

The extra docs are here https://docs.modx.com/extras/revo/rowboat/rowboat.rowboat. Shows you what you can do with Rowboat. Might help you debut further.

Also, for dev purposes it might be easy to change the content type back to HTML, that way you can see the output directly in the webpage without having to keep downloading a file.

— another side note. Make sure your using the empty template for the resource.

A bit of success. Name of formit forms table is different in latest MODx. System Info Database revealed name as modxvs_formit_forms
Mac Safari displays the content within the browser instead of downloading a file.
Chrome downloads to .tsv file

Content in both is messy though. Not so user friendly at the moment, but feel as though it’s very close to working.

Content could be messy if the tsv chunk isn’t formatted correctly. I’ve found I actually have to create the file in an IDE, then regex find and replace all spaces (\s) with tabs (\t). If you write the placeholders in your IDE with one space between (or use a newline for readability just replace (\n) instead) then find replace it should format tabs properly.

I’ve been able to clean up but still messy. If I export CSV from formit, the file opens up with a header row containing the form labels and content follows in the rows and cells below.

With RowBoat, the content is identical to how it’s displayed within the manger. At least in the manager, the labels are bold… and content regular weight, so visually easy to review. Not so much after download and viewing in Numbers or Excel.

I may give CSV a go and see it that gets me closer to have formit exports the CSV.

You’ll need to add in the header rows to the actual resource. Once you’ve called the data into Google sheets you can make the header row bold.

As for the values. They are being presented in JSON format. Might want to look at writing a snippet that decodes JSON to array then for each over the array outputting the data in a more readable format

Glad you got it working. Let us know how you get on.

1 Like

Thank you for your feedback, and encouragement. I don’t think I fully understand your response. Add header rows?.. as in building an HTML table and allow my css to format the headers? Or am I need to create a chunk with the header rows. Sorry… been away from MODx for a while here and trying to get back in the saddle. Each form submission is on it’s own line, which is great. Where is gets confusing is that the entire cell for values contains the header label (i.e first_name) following by the value, etc, and so on. I’m continuing to work with this… might experiment with CSV format for the resource too. As well… I wonder if FormIt has a method for doing this.

1 Like

What I believe @inside-creative was saying is that the data is encrypted and he didn’t know how to decrypt it.

Try to explain what the problem is now in terms of the output.

I also wonder if there could be an easier way now that we have been mulling on this for awhile…can formit simply produce each file and save it into a folder somewhere?

If formit automatically creates the file after submission and saves that file in some format, its trivial to output that list of files for download…

Maybe that’s no different than using Rowboat, I am not sure. Let’s focus in on what output you want and see if we can get it, before going on to alternate solutions.

The data exports. Safari though displays in the browser, while Chrome downloads the TSV. ==ImportFeed works terrific over at my google doc. [[+values]] though is displaying the same as it is in the FormIt Manager, which is tough to read. Working on JSON to decode, remove labels and put each item in it’s own cell.

1 Like