Forums

CSV Export v2 [GH] CFV4 export only one row query

marcinwolejko 15 Jul, 2014
Hi guys.
I'm back with a new question. I've been digging thought the forum to find the right answer but unfortunately I can't find any...

I have a form that is filled in by customers and the sent to us by e-mail. We gather the data to fill in the form in Excel that is provided by the gov. authorities. It would be much easier if we could simply import the customer data into that form using the csv file.

Hovewer, the only trouble is I need to somehow make the CSV export action to generate a file with only the data filled individually and not all the rows from the database and attach the download link to the email that is sent to us.

I guess the best option would be to identify the data by cf_id field.
IN the WHERE option box when I put `cf_id`={cf_id} (I found this solution somewhere on the forums) nothing gets exported.

Bob, please help🙂
marcinwolejko 15 Jul, 2014
Just to add to the case - when in the WHERE box I put for instance `cf_id`=5 it will generate csv file with only the data submitted with cf_id=5. So it seems the {cf_id} i use in the WHERE query needs to be replaced by something else or written in a different manner.... I just do not know how...😟
GreyHead 16 Jul, 2014
Hi marcinwolejko,

I'm away from my desk this week, sorry for the delay.

The code you have should work OK. How are you setting the value of cf_id ?

Bob
marcinwolejko 16 Jul, 2014
Hi Bob. Thanks for a reply.
It's an automaticallly generated value by chronoforms. Should I set it up as a hidden field in the form?
marcinwolejko 16 Jul, 2014
One more thing. I've got a custom code in the on submit action just before the export to csv action.
I tried both:
<?php
$form->data['cf_id'] = $form->data['chronoform_data']['cf_id'];
?>

and
<?php
echo '`cf_id` = '.$cf->id; ?>
$form->data['where'] = "`cf_id` = '{$cf->id}' ";
?>


but unfortunately with no luck...
GreyHead 16 Jul, 2014
Hi marcinwolejko,

Please try {chronoform_data.cf_id} If that doesn't work add a debugger action to check exactly where the cf_id is being saved.

Bob
marcinwolejko 16 Jul, 2014
Hmmm still nothing... here's the debugger output:
`CF_ID` = $FORM->DATA['WHERE'] = "`CF_ID` = '{$CHRONOFORM_DATA.CF_ID}' "; ?>DATA ARRAY: 
ARRAY
(
    [OPTION] => COM_CHRONOFORMS
    [CHRONOFORM] => AKCU
    [EVENT] => SUBMIT
    [ITEMID] => 
    [PLATNIL] => 
    [KRAJ] => POLSKA
    [WOJEWODZTWO] => PODLASKIE
    [POWIAT] => 
    [GMINA] => 
    [ULICA] => 
    [NR_DOMU] => 
    [MIASTO] => 
    [KODPOCZTOWY] => 
    [TELEFON] => 5678
    [EMAIL] => MD.WOLEJKO@GMAIL.COM
    [MARKA] => 
    [MODEL] => GHKJL
    [PRODUKCJA] => 
    [POJEMNOSC] => 
    [MOC] => 
    [SKRZYNIA] => 
    [NADWOZIE] => SEDAN
    [NAPED] => 
    [PRZEBIEG] => 
    [NR_NADWOZIA] => 
    [CENA] => 
    [WALUTA] => 
    [UC] => URZĄD CELNY W BIAŁYMSTOKU
    [DATA_NA_GRANICY] => 
    [FAKTURA_WYBIERZ] => NIE
    [UMOWADATA] => 
    [TLUMACZENIE] => 
    [DOWOD] => 
    [NRREJESTRACYJNY] => 
    [KRAJDOWODU] => 
    [TLUMACZENIEDOW] => 
    [WLASNOSC] => 
    [TLUMACZENIETYTULU] => 
    [NRZGLOSZENIA] => 
    [DATAZGLOSZENIA] => 
    [TLUMACZENIEZGLOSZENIA] => 
    [INPUT_SUBMIT_251] => SUBMIT
    [ZGODA] => 1
    [336F1EFC27129D3D98316F996EF2E629] => 1
    [IMIE] => 
    [NAZWISKO] => 
    [FIRMA] => 
    [FV] => 
    [CHRONOFORM_DATA] => ARRAY
        (
            [CF_UID] => B2A15FAB4CB663488E9D1A3142B51C25
            [CF_CREATED] => 2014-07-16 12:34:03
            [CF_CREATED_BY] => 475
            [CF_IPADDRESS] => 83.13.127.157
            [CF_USER_ID] => 475
            [OPTION] => COM_CHRONOFORMS
            [CHRONOFORM] => AKCU
            [EVENT] => SUBMIT
            [ITEMID] => 
            [PLATNIL] => 
            [KRAJ] => POLSKA
            [WOJEWODZTWO] => PODLASKIE
            [POWIAT] => 
            [GMINA] => 
            [ULICA] => 
            [NR_DOMU] => 
            [MIASTO] => 
            [KODPOCZTOWY] => 
            [TELEFON] => 5678
            [EMAIL] => MD.WOLEJKO@GMAIL.COM
            [MARKA] => 
            [MODEL] => GHKJL
            [PRODUKCJA] => 
            [POJEMNOSC] => 
            [MOC] => 
            [SKRZYNIA] => 
            [NADWOZIE] => SEDAN
            [NAPED] => 
            [PRZEBIEG] => 
            [NR_NADWOZIA] => 
            [CENA] => 
            [WALUTA] => 
            [UC] => URZĄD CELNY W BIAŁYMSTOKU
            [DATA_NA_GRANICY] => 
            [FAKTURA_WYBIERZ] => NIE
            [UMOWADATA] => 
            [TLUMACZENIE] => 
            [DOWOD] => 
            [NRREJESTRACYJNY] => 
            [KRAJDOWODU] => 
            [TLUMACZENIEDOW] => 
            [WLASNOSC] => 
            [TLUMACZENIETYTULU] => 
            [NRZGLOSZENIA] => 
            [DATAZGLOSZENIA] => 
            [TLUMACZENIEZGLOSZENIA] => 
            [INPUT_SUBMIT_251] => SUBMIT
            [ZGODA] => 1
            [336F1EFC27129D3D98316F996EF2E629] => 1
            [IMIE] => 
            [NAZWISKO] => 
            [FIRMA] => 
            [FV] => 
            [CF_ID] => 37
        )

    [CHRONOFORM_DATA_CF_ID] => 37
)
VALIDATION ERRORS: 
ARRAY
(
    [CSV EXPORT] => NO RECORDS WERE FOUND TO EXPORT.
)
YOU MAY DOWNLOAD YOUR FILE FROM HERE . RECORDS WERE EXPORTED. THE FILE SIZE IS KB. DEBUG DATA
 CSV EXPORT
$DOWNLOAD_EXPORT: 0	 $DOWNLOAD_NOSAVE: 0	 SAVE FOLDER IS: 
/HOME/USERS/TERMINUS_EPI/PUBLIC_HTML/COMPONENTS/COM_CHRONOFORMS/EXPORTS/AKCU/	 $DOWNLOAD_EXPORT: XXX	 $DOWNLOAD_EXPORT: 0	 FILE NAME IS: 
CSV_EXPORT_TP6CF_CHRONOFORMS_DATA_AKCU_201407161234.CSV	 $QUERY: SELECT * FROM `TP6CF_CHRONOFORMS_DATA_AKCU` WHERE {WHERE} ;


The custom code right now is:
<?php
echo '`cf_id` = '.$cf->id; ?>
$form->data['where'] = "`cf_id` = '{$chronoform_data.cf_id}' ";
?>


I'm sorry for being such a nuisance but I'm really lost😟
GreyHead 16 Jul, 2014
Answer
1 Likes
Hi

You can see the mySQL query being created is SELECT * FROM `TP6CF_CHRONOFORMS_DATA_AKCU` WHERE {WHERE}

So $form->data['where'] isn't being defined correctly.

Please just try this in the WHERE box
`cf_id`= {chronoform_data_cf_id} 
There should be no need for Custom Code.

Bob
marcinwolejko 17 Jul, 2014
Bob,
I can't thank you enough!😀

Works like a charm!
Brian ter Braak 08 Sep, 2014
Hello,
i have the same problem and can't fixt it. I get in in excel but every data in one rox and one cel, I would like to have different cel's for all the area in the form I made.
I made a form in CF 4.0.1. After the wizzard i go to actions and then data export. select de csv export. Config. with the data table I choose.
Whats going wrong?

If its possible answer back in Dutch?
GreyHead 08 Sep, 2014
Hi Brian ter Braak,

If its possible answer back in Dutch?, Sorry, but no, I'm sure that your English is better than my Dutch. Google translate should help you.

This thread is about the CSV Export [GH] action, are you using that or the standard ChronoForms CSV Export action?

Bob
This topic is locked and no more replies can be posted.