Help get this topic noticed by sharing it on Twitter, Facebook, or email.

Uploading Attachments

I have a PDF file I want to attach to a person account in a nightly batch process. I've been able to upload it as a document using the SF_UploadFile stored procedure, but I dont see how to attach it to the person account. I'm thinking I need to upload an attachment instead of a document, but I'm unclear on how to do this (specifically what to put as the required 'body' field in the attachements table). Thanks for the help.
1 person has
this question
+1
Reply
  • Here is an example of how to upload an local file to an attachment connected to an Account record:

    CREATE TABLE [dbo].[Attachment_Ins](
    [Id] [nchar](18) NULL,
    [Error] [nvarchar](255) NULL,
    [ContentType] [nvarchar](120) NULL,
    [Description] [nvarchar](500) NULL,
    [IsPrivate] [varchar](5) NOT NULL,
    [Name] [nvarchar](255) NOT NULL,
    [OwnerId] [nchar](18) NOT NULL,
    [ParentId] [nchar](18) NOT NULL,
    [Body] [nvarchar](255) NULL
    )
    go

    INSERT INTO [Attachment_Ins]
    ([Id]
    ,[Error]
    ,[ContentType]
    ,[Description]
    ,[IsPrivate]
    ,[Name]
    ,[OwnerId]
    ,[ParentId]
    ,[Body])
    VALUES
    (''
    ,''
    ,''
    ,'Test Description'
    ,'false'
    ,'Test Attachment'
    ,'00530000000kQi6AAE'
    ,'0013000000AIjzpAAD'
    ,'c:\test.pdf')
    GO

    exec SF_BulkOps 'Insert','SALESFORCE','Attachment_Ins'

    Note that you must be running version 2.14.1 or later to use this technique.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned

  • great - I will give it a try. Thanks for the quick reply.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned