Export CSV Operation

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
rbross
Posts: 441
Joined: Wed Nov 19, 2014 4:13 am
Location: Coventry, Connecticut USA

Export CSV Operation

Post by rbross »

Hello,

AwareIM has an operation called Export CSV which will export the data of the current query to a CSV file and download it to the local machines downloads directory automatically.
How come the EXPORT function used in a process does not work the same way or give you this option?
You have to specify a path and filename, but there is no option to download the exported file.

When data is exported by a user how do they get access to the exported file to download it?
Roger Ross
AwareIM 8.7 (build 3025) ~ MS-SQL ~ Windows 10 ~
AwareIM 8.5 (build 2828) ~ MS-SQL ~ Windows 10 ~
ACDC
Posts: 1146
Joined: Sat Jun 30, 2007 5:03 pm
Location: California, USA

Re: Export CSV Operation

Post by ACDC »

This should work :
1. EXPORT the file to disk on the server with the .csv extension
2. IMPORT the same file to a Document Attribute on the relevant object
3. And then use DISPLAY DOCUMENT Object.DocAttribute (This will open the file on the client and because it is a .csv it will ask the client to open with ? or save file to disk

Alternatively, if you have the file created in the report writer as a textfile.csv, you could just use DISPLAY DOCUMENT 'REPORTNAME' and the same window will open on the client side - open with ?/ or save
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: Export CSV Operation

Post by tford »

Very creative solution ACDC!
Tom - V8.8 build 3137 - MySql / PostGres
rbross
Posts: 441
Joined: Wed Nov 19, 2014 4:13 am
Location: Coventry, Connecticut USA

Re: Export CSV Operation

Post by rbross »

Thx I'll try that.
I did something similar creating a report but with an Excel file.
Using:
<<LIST_TABLE_START('Contacts_To_Excel')>><<Contact.ContactLastName>>
<<Contacts.OtherAttributes>>
<<Contact.EmailAddress>><<LIST_TABLE_END()>>

Would I have to do the same thing in a text file?

Doing an Export in a process then import and display document maybe faster though...
Roger Ross
AwareIM 8.7 (build 3025) ~ MS-SQL ~ Windows 10 ~
AwareIM 8.5 (build 2828) ~ MS-SQL ~ Windows 10 ~
rbross
Posts: 441
Joined: Wed Nov 19, 2014 4:13 am
Location: Coventry, Connecticut USA

Re: Export CSV Operation

Post by rbross »

ACDC wrote:This should work :
1. EXPORT the file to disk on the server with the .csv extension
2. IMPORT the same file to a Document Attribute on the relevant object
3. And then use DISPLAY DOCUMENT Object.DocAttribute (This will open the file on the client and because it is a .csv it will ask the client to open with ? or save file to disk
RESOLVED... :!:
This method works really fast when exporting data ACDC!
When you import the file and then use DISPLAY DOCUMENT it automatically downloads the CSV file for you. It displays nothing, which is exactly how I wanted it to work. Its shows that the file was downloaded on the bottom of the browser.

One caveat is if you are exporting over 1000 records you need to do the export in a separate process using EXCLUDE RELATIONSHIPS and APPEND then have a process to do the import and display document.
I did this by having 3 processes
Export_Contacts_A
Export_Contacts_B
Export_Contacts_C
Export_Contacts_A does nothing but calls B and C.
The reason for this is if you have the import rule in the same process as the export rule it will only import the last 1000 records because Aware is exporting the records in Batches of 1000. The entire Export needs to finish before the import and display document can be done.
Process_B does the following:
DELETE FILE 'filepath/'filename.csv
Find All Contacts
EXPORT Contacts TO 'filepath/'filename.csv

Process_C does the following: using a non-persisted BO
CREATE VirtualBO WITH VirtualBO.Date=CURRENT_DATE
IMPORT DOCUMENT VirutalBO.Document FROM 'filepath/'filename.csv
DISPLAY DOCUMENT VirutalBO.Document

I do the CREATE ONLY to have the VirtualBO in context then I update the Document attribute with the CSV file.
Not sure if just doing a CREATE VirutalBO WITH VirutalBO.Document= 'filepath/'filename.csv would work without using the IMPORT DOCUMENT that's the only reason I did the CREATE then the IMPORT DOCUMENT.

Thank you for the TIP ACDC :D :D :D
Roger Ross
AwareIM 8.7 (build 3025) ~ MS-SQL ~ Windows 10 ~
AwareIM 8.5 (build 2828) ~ MS-SQL ~ Windows 10 ~
ACDC
Posts: 1146
Joined: Sat Jun 30, 2007 5:03 pm
Location: California, USA

Re: Export CSV Operation

Post by ACDC »

Thank you for the TIP ACDC :D :D :D
You're most welcome, glad you found a solution :)
rbross
Posts: 441
Joined: Wed Nov 19, 2014 4:13 am
Location: Coventry, Connecticut USA

Re: Export CSV Operation

Post by rbross »

Solved but not solved!!!

When running this process on the server in the cloud, the process will display the report but will not download the csv file. If I use PRINT DOCUMENT then the report is getting sent to my local printer even when I am not the user running the process.... ( I have another post on that issue as well!)
Does Aware IM have an issue with using DISPLAY DOCUMENT twice in two different processes that are part of the overall main process?

The first DISPLAY DOCUMENT displays the report the 2nd one downloads the csv file. When a similar process is run that only prints for one donor then the report displays and the csv file gets downloaded, but when there is more than one donor it is not working on the cloud server. Seems to work fine when I run it on my local machine???
Roger Ross
AwareIM 8.7 (build 3025) ~ MS-SQL ~ Windows 10 ~
AwareIM 8.5 (build 2828) ~ MS-SQL ~ Windows 10 ~
ACDC
Posts: 1146
Joined: Sat Jun 30, 2007 5:03 pm
Location: California, USA

Re: Export CSV Operation

Post by ACDC »

PRINT DOCUMENT is a server-based function that outputs the document to the Lpt1 port or designated print queue on an AwareIM server. You would only use this function if your AwareIM server is running on a local intranet and serving a particular print queue for users on the LAN

The fact that you are developing on your local machine and your AwareIM server is also local, PRINT DOCUMENT seems to work, but it won't work when you go to the cloud or WAN. This is probably what's confusing you. Forget about using PRINT DOCUMENT

As to DISPLAY DOCUMENT, this is all that you have to work with. When you DISPLAY DOCUMENT a PDF, it automatically opens the PDF in your browser because you have a PDF reader installed on your machine and its associated to the default file extension .pdf . If you had no PDF reader installed, the result of a DISPLAY DOCUMENT action would be a pop up window prompting you to "save file" or "open with" or autosaving in the background to a given folder,depending on browser settings. So it depends on how your users browser is set up and also if there is a default association with regards to the application(in this case) that opens a .csv file. (normally a .csv file does not have a default association). So the behaviour is, download file in background or prompt users to save. The same goes for a .DOC file , if WORD is not installed on the users machine it would prompt the user to " Save or Open with"

Also bear in mind , if there is no default association to the file extension on the users machine and the Browser Download settings are set to automatcally download to a specific folder, there would be no prompting of the user to "open or save to" it just goes ahead with the download in the background.

I cant see why you have 2 x DISPLAY DOCUMENT in your process - so I can't comment on the this one, but hopefully what i have described above, puts things in a better perspective for you to resolve your problem
rbross
Posts: 441
Joined: Wed Nov 19, 2014 4:13 am
Location: Coventry, Connecticut USA

Re: Export CSV Operation

Post by rbross »

ACDC wrote:I cant see why you have 2 x DISPLAY DOCUMENT in your process - so I can't comment on the this one, but hopefully what i have described above, puts things in a better perspective for you to resolve your problem
Thanks for the response.
Not sure if I ever gave the full picture here!
The reason for two DISPLAY DOCUMENTS is this; the first one displays a Thank You Letter for Donor's, the second one downloads a csv file with the exported addresses for each donor to be used in a Mail Merge in WORD to print envelopes. I tried to create a report in Aware to print an envelope but I could not get the text to print in the right direction, so I decided to try doing the export of each address and append them to a csv file. It seems to work fine when I only have one letter to print and one address in the csv file. The user can go to the donation detail record for the donor and print the thank you letter, it will display the letter in a PDF so they can print it and then the csv file will get downloaded. This issue is when the user prints thank you letters for a batch that contains many donations that could have several flaged for thank you letters. It will display the pdf for the thank you letters but it will not download the csv file with all the addresses. I also tried doing a PRINT DOCUMENT for the thank you letters and a DISPLAY DOCUMENT for the csv file but the thank you letters did not print for the user, it worked fine for me on my local machine. Which you explained as to why this will not work on a cloud-based server.

Another option I thought of was to not create the csv file at all and adjust the thank you letter' formatting so the donor's address will display in an envelope with a window, no need for a csv file if this works and the customer is OK with using envelops with windows.

Thank you again for the explanation.
Roger Ross
AwareIM 8.7 (build 3025) ~ MS-SQL ~ Windows 10 ~
AwareIM 8.5 (build 2828) ~ MS-SQL ~ Windows 10 ~
Post Reply