Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have built a webservice in salesforce so that it is being consumed from SAP. So, when a sales order is created in SAP, it would call the salesforce webservice and post the sales order details and also a pdf file as xstring (a data type in SAP). I have used blob field to get the pdf file from SAP. Now, i need to persist the data in that blob field to a field in one of the custom object.

Is there any equivalent data type in standard or custom object to store blob data? Please suggest.

 global without sharing class  SOBlockWebService{
        //webService static List<SOBlockResponseDTO> getSOBlock(List<SOBlockRequestDTO> SOBlock)  
        webService static void getSOBlock(List<SOBlockRequestDTO> SOBlock)
                List<SOBlockResponseDTO> lstSOBlockDTO = new List<SOBlockResponseDTO> {};
          //************************remaining code goes here*************

and the inner class to handle the input. Here, i have declared a blob variable to get the pdf file stream from SAP. Is that correct data type for the file stream?

global class SOBlockRequestDTO {
        webservice String ApplicationType {get;set;}
        webservice String CustomerNumber {get;set;}
        webservice String DocDate {get;set;}
        webservice String DocTime {get;set;}
        webservice String Timestamp {get;set;}
        webservice String Message {get;set;}
        webservice String Context1 {get;set;}
        webservice String Context2 {get;set;}
        webservice String Context3 {get;set;}
        webservice String Context4 {get;set;}
        webservice String Context5 {get;set;}
        webservice String Context6 {get;set;}
        webservice String Status {get;set;}
        webservice Blob PDFAttachment {get;set;}

        public SOBlockRequestDTO(String ApplicationType,String CustomerNumber, String DocDate, String DocTime, String Timestamp, String Message, String Context1, String Context2, String Context3, String Context4, String Context5, String Context6, String Status, Blob PDFAttachment) {
            this.ApplicationType = ApplicationType;
            this.CustomerNumber = CustomerNumber;
            this.DocDate = DocDate;
            this.DocTime = DocTime;
            this.Timestamp = Timestamp;
            this.Message = Message;
            this.Context1 = Context1;
            this.Context2 = Context2;
            this.Context3 = Context3;
            this.Context4 = Context4;
            this.Context5 = Context5;
            this.Context6 = Context6;
            this.Status = Status;
            this.PDFAttachment = PDFAttachment;
share|improve this question
up vote 2 down vote accepted

Baskaran, there is no direct equivalent field type to Blob data type in salesforce.

here's an open idea if you are interested.

your options would be

  • store the pdf as an Attachment linked to the record you are creating/updating
  • store the file as a document and have a link to the document in a custom field in your custom object..
  • store the file content into rich text / long text area field (not a good option as you have size limits)

you can then have a visualforce page that can display the pdf file from one of the above options which you can embed into the custom object page layout..

also, i noticed you have marked all your variables in the class as webservice which is not required. marking the method as webservice alone should be fine.

share|improve this answer
Attachment is likely the best option. Then you get the security for free. Additionally, if there will ever only be one document attachment, you can make some easy assumptions in your code if you need to reference it elsewhere. – Andrew Monshizadeh Aug 16 '14 at 14:03
Thanks Vamsi. I will update the code. – Baskaran S Aug 16 '14 at 15:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.