Uploading .txt file to Salesforce - salesforce

In our company we receive files from the banks in .txt format, where information about each payment from a customer is stored as numbers. I want to upload this file to Salesforce, but it seems like it's not possible to upload .txt files to Salesforce, only .csv. What I am trying to do is to parse them based on a set of rules and put each one of these payments in their own record in a "Payments" object.
Is there any way to do this using Apex or Visualforce? Or both?

You will need to convert it to a csv file, so it will need to be a manual job. You could write a script to do it for you but as for native Salesforce functionality there isn't anything

Using a VF page it can be done. It's rather complex (and it might be easier to convert the files to .csv and use the Data Loader), but it could be fun.
First, create a VF page that uses a StandardController for Payment__c (might not be required, depending on what you want to do) and an extension MyControllerExtension. In the VF page, provide a apex:inputFile component to get the .txt file.
When the file is selected, call a function in MyControllerExtension that will parse it into separate Payment__c records.
Finally, use a standard DML call to insert them insert myPaymentsList.

Related

is it possible store PDF or HTML content in snowflake.Please help us what is the best data type to store PDF or HTML data. How to retrieve that

is it possible store PDF or HTML content in snowflake.Please help us what is the best data type to store PDF or HTML data. How to retrieve that
If you just want to store HTML or PDF for any technical reason, you can use binary date type which can store such files up to 8Mb size. However, you could not query binary date type directly in your query.
If you have to extract any information, you can use python CLI and use python libraries to extract additional information, but you can not use SQL to extract any information.
HTML can be saved as XML but you can try that as it has couple of limitation and not sure if XML parsing is available in GA or still preview.
Snowflake has new unstructured data storage and querying functionality now. You can store the PDF in a stage and use a directory table to view the file list within the stage. You can create scoped URL's, etc. to allow applications to render the PDF files, etc.

How to filter body content in an Azure Logical Apps

My basic workflow is this: I check an FTP server for a specific file. If the file exist, I pick up the file and sends it to a Blob Storage. My problem is this: I want to filter the file content, eg. remove first and last row since they dont contain any real data before I send it to the blob. The first row consist of a time stamp and the last row contains a "row count". The file contains comma separated fields. How do I accomplish this? Is it even possible?
Thanks
Ausgar
There is no simple solution for this problem. You can try converting csv to json, delete unnecessary data from it, and create a blob based on that json, but this is sounds harder than it should be.
Consider using Azure functions:
Azure Functions allows you to run small pieces of code (called
"functions") without worrying about application infrastructure. With
Azure Functions, the cloud infrastructure provides all the up-to-date
servers you need to keep your application running at scale.
It will be much easier to do such file manipulation there.

Data Extraction from PDF

I get 15+ PDF's a day that I have to enter into a database. They are generated from a table where the "Blanks" are filled in from specific table fields. Any tools or python code examples I could use to try and develop a means of extracting the data from the PDF to either write to or create a table to import to the database table? The Database is currently Access mdb.
Thanks
There are a number of approaches that will work.
One simple approach is to simply print the PDF file out to a text file and then have Access import that text. All recent versions of windows allow you to install a “text” printer that outputs the printing of a document to a text file. You can have access “process” a folder of pdfs, print them to text and then import those text files. You might need some VBA to remove “pages” and some extra lines before you import the data into Access.
Another approach is to use Word (Automate from Access) to open a PDF. When word opens a pdf, it converts it to a word document. This approach will even format rows as a word table. You can then pluck out that table data and send that data to word. You can likely pull that text out without writing the data out to a text file – or just use Words “save-as” to a text file (you can automate this process from Access).
Another approach is to use the free Ghost Script library that can extract text from a PDF (this I would consider if did not have word at your disposal).
So which solution is best will much depend on the current software you going to have installed on the computer running Access. Opening the pdf files with word would be my first choice and test.
At my old job we used Cogniview which converted PDF to Excel spreadsheets quite quickly. If you want to use Python, a quick search yielded me this which seems straight forward enough, PDF to XLS with Python

File Maker Scripting - Sending Different Attachment

Is there a way to send a mail with different PDF file to different contacts using file maker?
I am aware of sending batch emails with one attachment but I would like to send a personalize PDF for each contact which seems not so simple.
Also
Can I add PDF files to the table itself or would I have to use the path to the file?
Example:
Table 1
**Name** [James Brown] [James Blue]
**Email** [brown.j#gmail.com] [blue.j#gmail.com]
**PDFfileAttchamnet** [folder/PDF/JamesBrown.pdf] [folder/PDF/JamesBlue.pdf]
So an Email for James Brown would look like:
Dear James Brown, please see the attached file.
Attachment [JamesBrown.pdf] {actual file}
and
Dear James Blue, please see the attached file.
Attachment [JamesBlue.pdf] {actual file}
I think you can solve it by creating container field in you database and import the pdfs in it.
then you can use export Field Contents[] to export it and send it by email
Hope it useful
I would like to send a personalize PDF for each contact which seems
not so simple.
Find the records of contacts you want to include and loop among them, sending mail to each one individually (i.e. without selecting the 'Collect addresses across found set' option).
Can I add PDF files to the table itself or would I have to use the
path to the file?
You can do either, it's up to you. If the path to the file can be calculated (as in your example), you can calculate it right there in the Send Mail script step.
Note that you can also generate the PDF files during the process itself.
Do I understand correctly that you would actually like to personalize the PDF document(s)?
This is possible, maybe not very simple, but quite simple. The trick is to prepare the PDF as a form, and then fill the form fields to personalize.
PDF has a native forms data format (called FDF), which is described in ISO 32000 (as well as the older PDF specification documents provided by Adobe, as you can find in the Acrobat SDK, downloadable from the Adobe website).
FDF is a simple structured text file, which can easily be assembled using FileMaker (I have done that routinely for several catalog projects). The easiest way to get going is to open the form in Acrobat, fill in the fields, and then export the data as FDF. This gives you the pattern to "fill in the blanks".
So, you create the FDF files using Filemaker. With them you can fill the blank form and feed the saved document to the eMail system.
Which tool to use to fill the blank form depends on the volume you have to process. Acrobat is not very powerful (and you may end up in a bit of a legal gray zone, because Acrobat is not set up for being used as a service). There are applications which are made specifically for filling out forms on a server (such as FDFMerge by Appligent), or there are also several libraries which have the tools to fill out forms (iText or pdflib come to my mind). These applications also allow you to flatten the PDF, which means that there are no longer form fields, but their contents becomes part of the base.
The resulting file can now be either made to an eMail attachment, or you make it available on a server and send an eMail with the link to the file (which method you will use may depend on security and privacy regulations).

Creating Excel File in Apex code

'm wondering is it possible to create Excel or CSV file in apex code (as attachment) is it possible ? currently i only see it works with VF page, but i'm looking to do it in apex code not using vf page, I don't see any options.
Any help is appreciated.
Thanks
Unfortunately there is no native CSV Library or API in Apex to handle the creation of CSV files. Certainly not XLS documents although you could use the native XML DOM libraries to create an Excel friendly XML document.
To write a CSV, this should be fairly simple; it's basically a big huge string with a carriage return and/or line feed at the close of each full record write. You'll need to carefully manage property value escapement by using String.replaceAll('\','\''); etc. Which in turn will chew up your script statements pretty badly.
Next, create a new Document(), convert your string to a Blob using Blob.valueOf(String) and instantiate that blob as the body of the Document.
If you are planning on writing a very large document, you may want to consider writing to some other format type or offloading this processing to a remote system (EC2?) and letting it respond with the Document in time.
I have some Apex CSV utilities already written if you need them.

Resources