Skip to main content
Question

Button to export CSV from parent record

  • Sep 15, 2017 7:54 PM UTC
  • 5 replies
  • 95 views

I'm trying to have the user click on a button in a parent record form, which will then download the detail records from a child table related to that parent, in CSV format. I know I can easily create a button that downloads a specific report to CSV using the URL of the report, but when I try this it downloads the whole report, not just the records related to the parent.

How can I accomplish this? Thanks in advance.
This topic has been closed for replies.

5 replies

Low tech is to use the "More .." button on the blue bar at the top of the embedded child table.

True, but I'm trying to make it idiot-proof for my users. A big button that screams CLICK ME TO DOWNLOAD goes far.

I am sorry, but I can totally relate to this pain.

Ya, its doable.
I will outline the steps and and let me  known if you need more detail.

Make an <ask the user> report on the child with your export columns.  The <ask the user> is for [Related Parent]. Set the report at the very bottom to be in CSV format.
Run the report manually and observe that it works and observe the URL - we need to mimic that URL in a button.

URL formual

urlroot() & "db/" & [_DBID_of my child table] & "?a=q&qid=xx&nv=1&v0=" & [Record ID#]

that says:
Run the report on the Child  table with the report ID =xx (which you will fill in) 
and it will have 1 question (nv = number of variables = 1) and the zeroth variable is [Record ID#]

It starts counting at zero.

Perfect! Thanks!