Mass Upload Files To Specific Contacts Salesforce - csv

I need to upload some 2000 documents to specific users in salesforce. I have a csv file that has the Salesforce-assigned ContactID, as well as a direct path to the files on my desktop. Each contact's specific file url has been included in the csv. How can I upload them all at one and, especially, to the correct contact?

You indicated in the comments / chat that you want it as "Files".
The "Files" object is bit more complex than Attachments, you'll need to do it in 2-3 steps. What you see as a File (you might see it referred to in documentation as Chatter Files or Salesforce Content) is actually several tables. There's
ContentDocument which can be kind of a file header (title, description, language, tags, linkage to many other areas in SF - because it can be standalone, it can be uploaded to certain SF Content Library, it can be linked to Accounts, Contacts, $_GOD knows what else)
ContentVersion which is well, actual payload. Only most recent version is displayed out of the box but if you really want you can go back in time
and more
The crap part is that you can't insert ContentDocument directly (there's no create() call in the list of operations) .
Theory
So you'll need:
Insert ContentVersion (v1 will automatically create for you parent ContentDocuments... it does sound bit ass-backwards but it works). After this is done you'll have a bunch of standalone documents loaded but not linked to any Contacts
Learn the Ids of their parent ContentDocuments
Insert ContentDocumentLink records that will connect Contacts and their PDFs
Practice
This is my C:\stacktest folder. It contains some SF cheat sheet PDFs.
Here's my file for part 1 of the load
Title PathOnClient VersionData
"Lightning Components CheatSheet" "C:\stacktest\SF_LightningComponents_cheatsheet_web.pdf" "C:\stacktest\SF_LightningComponents_cheatsheet_web.pdf"
"Process Automation CheatSheet" "C:\stacktest\SF_Process_Automation_cheatsheet_web.pdf" "C:\stacktest\SF_Process_Automation_cheatsheet_web.pdf"
"Admin CheatSheet" "C:\stacktest\SF_S1-Admin_cheatsheet_web.pdf" "C:\stacktest\SF_S1-Admin_cheatsheet_web.pdf"
"S1 CheatSheet" "C:\stacktest\SF_S1-Developer_cheatsheet_web.pdf" "C:\stacktest\SF_S1-Developer_cheatsheet_web.pdf"
Fire Data Loader, select Insert, select showing all Salesforce objects. Find ContentVersion. Load should be straightforward (if you're hitting memory issues set batch size to something low, even 1 record at a time if really needed).
You'll get back a "success file", it's useless. We don't need the Ids of generated content versions, we need their parents... Fire "Export" in Data Loader, pick all objects again, pick ContentDocument. Use query similar to this:
Select Id, Title, FileType, FileExtension
FROM ContentDocument
WHERE CreatedDate = TODAY AND CreatedBy.FirstName = 'Ethan'
You should see something like this:
"ID","TITLE","FILETYPE","FILEEXTENSION"
"0690g0000048G2MAAU","Lightning Components CheatSheet","PDF","pdf"
"0690g0000048G2NAAU","Process Automation CheatSheet","PDF","pdf"
"0690g0000048G2OAAU","Admin CheatSheet","PDF","pdf"
"0690g0000048G2PAAU","S1 CheatSheet","PDF","pdf"
Use Excel and magic of VLOOKUP or other things like that to link them back by title to Contacts. You wrote you already have a file with Contact Ids and titles so there's hope... Create a file like that:
ContentDocumentId LinkedEntityId ShareType Visibility
0690g0000048G2MAAU 0037000000TWREI V InternalUsers
0690g0000048G2NAAU 0030g000027rQ3z V InternalUsers
0690g0000048G2OAAU 0030g000027rQ3a V InternalUsers
0690g0000048G2PAAU 0030g000027rPz4 V InternalUsers
1st column is the file Id, then contact Id, then some black magic you can read about & change if needed in ContentDocumentLink docs.
Load it as insert to (again, show all objects) ContentDocumentLink.
Woohoo! Beer time.

Your CSV should contain following fields :
- ParentID = Id of object you want to link the attachment to (the ID of the contact)
- Name = name of the file
- ContentType = extension(.xls or .pdf or ...)
- OwnerId = if empty I believe it takes your user as owner
- body = the location on your machine of the file (for instance: C:\SFDC\Files\test.pdf
Use this csv to insert the records (via data loader) into the Attachment object.
You will then see for each contact, that records have been added to the 'Notes & Attachments' related list.

Related

Generating Date Range in Google Sheets

I have a Google Sheet that contains extracted metadata from a large amount of files that I transferred from CDs to a server. I am currently working on creating a description for these materials to include in a finding aid. I found it easiest to work in Excel or Sheets because the PUI we use to output our finding aids utilizes a spreadsheet upload plugin.
I've been using pivot tables in Google Sheets to sort through all of the data with little issue except when I need to generate a date range for the files contained in one CD. Essentially, I'm creating a pivot table that contains rows for the URI, Filename (in this case I'm filtering for folder name only), and date_modified. The data looks something like this:
URI
FILENAME
DATE_MODIFIED
URI1
FOLDER1
2000-01-01
URI1
FOLDER2
2000-01-01
URI1
FOLDER3
2000-02-01
URI1
FOLDER4
1999-12-02
URI2
FOLDER1
2001-01-20
... and so on.
I'd like to generate a date range for each unique URI. I realize I could just go through each unique URI and manually extract that data but I have a LOT of these to go through so I don't think it is the most efficient use of my time. Especially, when you notice that the dates do not follow a chronological order. I'm thinking that pivot tables are not going to help me here so if anyone has other suggestions I'm happy to listen but brownie points if anyone has a solution that works in Sheets!
Try this on a new tab somewhere.
=QUERY(Sheet1!A:C,"select A,MIN(C),MAX(C) where A<>'' group by A")
change the range ref to suit.
Then in the next column over, depending on where you output the query,
=IF(A2="",,TEXT(B2,"yyyy-mm-dd")&"-"&TEXT(C2,"yyyy-mm-dd"))
drag down to the bottom.

How do I download only my purchase invoice documents from Exact Online with Invantive Query Tool?

To comply to regulations, I'm trying to download the purchase invoice documents (as PDF files) from some of my divisions to save them on-disk for archiving purposes.
I use Invantive Query Tool to do this. I like to know which table to use and how to export these attachments only regarding purchase invoice documents.
You can indeed do this by using the export options in Invantive Query Tool or Invantive Data Hub.
What you need is a query that hooks up the document information of type 20 (purchase invoices) with the actual attachment files. You can find a list of types and their description in the DocumentTypes view. You can find the document attachment files in the DocumentAttachmentFiles table.
When you have retrieved that, you can export the documents from that query to disk using a local export documents statement.
The full query is here:
use 123456
select /*+ join_set(dae, document, 10000) */ attachmentfromurl
, dct.division || '/' || dae.id || '-' || filename
filepath
from exactonlinerest..documents dct
join DocumentAttachmentFiles dae
on dae.division = dct.division
and dae.document = dct.id
where dct.Type = 20
order
by dct.division
, dae.id
local export documents in attachmentfromurl to "c:\temp\docs" filename column Filepath
Make sure to set the ID of the division right in the use statement (this is the technical ID, not the 'division number', which can contain duplicates). You can find that in the top menu bar under Partitions. Or simply use use all to get the documents from all divisions (this might take a while).
Also set the file path right where it says c:\temp\docs now. Then hit F5 in the Query Tool to execute, or run the script from Data Hub.

Display image with wildcard in src

I have a series of photos on a server with a strict naming convention: "uniqueId-readableName.jpg". I do this because my website database currently only logs the uniqueID (and some unrelated info), but people occasionally need to look at the file server directly to browse the photos (via FTP) so a readable name is useful. For example
001456-War Horse.jpg
003295-Sunshine Daiseys.jpg
129084-Laboring at the farm 2013-08-11.jpg
Now, I'm fairly sure the best option would be to set up the database with a record of the full file names, but I just wanted to see if anyone had any ideas I may have missed. This question on SO is similar, but here I have strict naming conventions - not sure if that opens up any possibilities or not.
I'm applying this to img, but the same idea could be appled to any file extension (eg, download "789-My Homework.zip" or "123-Family vacation.zip").
As an example of what I'm looking for, in Windows Explorer you can do a file search for
0*.jpg
and all of the following files can be returned
001456-War Horse.jpg
003295-Sunshine Daiseys.jpg
029084-Laboring at the farm 2013-08-11.jpg
In my case the beginning part is always unique, so I'd like to use something like 001456-*.jpg and have it return 001456-War Horse.jpg.
Is there any way do this on a website?
<img src="001456-*.jpg" />
Although no such method exists, you can still do a server side scripting to acheive the functionality you require.
For example in PHP you could use in-built commands to browse a folder, select all files matching the criteria name as '001456-*.jpg' and then depending upon the number of records returned select the first filename and insert it into an IMG tag.
Here is a sample implementation in PHP:
$files = array();
$id = "001456";
$files = glob("id-*.jpg");
echo "<img src='$files[0]' />"; //Assuming one file is found for every unique ID.

translate html table to csv

So.. I am a little confused on this problem myself so I am turning to the one place I know I am certain to find help!
I have a shopping cart where in order to purchase something a user must first fill out a form. At the end I am displaying the information they entered in the form along with the product they are purchasing, how much they are paying and any sort of modifiers the product might have (like size, color, shipping etc etc). I have a third party company that then needs to retrieve that information in a CSV file.
Any ideas on how this can be achieved. I am new at this sort of thing so I apologize if I may have missed this somewhere else on the forum.
Thanks!
Jamie
This is actually not too hard! A CSV files is just a comma separated values file.
Whatever you are using as a backend (PHP, c#, c) you can write to a file like so:
CustomerID, Name, Item1
1, John, Table
and that would appear in excel as CustomerID Name and Item1 as the header row and 1, John, Table as the first record. Make sure that when you create the file you call it MyFile.CSV so it is associated with Excel by windows!
Look here for how to properly format your CSV file!
http://creativyst.com/Doc/Articles/CSV/CSV01.htm
EDIT:
I see now you say HTML table so in the case you have no server code access I direct you here for more info.
Export to csv in jQuery

Retrieving All Payments From Sage Line 50 Database

I'm trying to retrieve a list of all payments received/entered into a Sage Line 50 database. The company I work for are members of the Sage developer program, so I have access to the SDK, help files and the like but I have been unable to find any specific information regarding payments.
Some of the .dta files contain references to payments (SPLITS.DTA & HEADER.DTA) alongside Invoice rows.
Does anyone know whether or not there is a separate file which contains only payment information, and if so what is it? Alternatively, will I have to pull the full list of rows from the SPLITS/HEADER files and filter them by type?
Many thanks in advance
I pulled data from the Header and Split files for a test customer this afternoon, and they contain (as near as I can tell) all customer activity - Invoices, Invoice payments and Credits are all reflected in both data files (the split data file containing more in depth data) and can be filtered by bank_code and transaction type.
To get the data - first create a reference to a customer object and from there link to all of the header (assuming you have an existing connection and workspace).
dynamic workspace = this._workspaces[workspaceName];
dynamic customer = workspace.CreateObject("SalesRecord");
bool added = customer.AddNew();
customer.MoveFirst(); //find first customer
dynamic headerObject = customer.Link;
bool headerFound = headerObject.MoveFirst(); //use .MoveNext() to cycle headers
You can then pull data from the header object using :
string AccountRef = headerObject.Fields.Item("ACCOUNT_REF").Value;
Where ACCOUNT_REF is a field in the HeaderData object.
Use the following code to get split data
dynamic splitObject = headerObject.Link;
bool splitFound = splitObject.MoveFirst() //and so on