function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
abhishekj25abhishekj25 

Documemt Class : Constructor not defined

Hi All,

 

I want to create functionality for uploading image or logo in salesforce.

I am facing an issue when I tried to create an object of standered object Document in Unlimited Edition with 28.0 version.

 

Below is code :

 

public with sharing class UploadLogoForProfiles

{

  public Document document {
    get {
      if (document == null)
        document = new Document();

         // Error: Compile Error: Constructor not defined: [Document].<Constructor>() at line 6 column 20
      return document;
    }
    set;
  }
 
  public PageReference upload()

  {
 
    document.AuthorId = UserInfo.getUserId();
    document.FolderId = UserInfo.getUserId();
 
    try

         {
           insert document;
          }

         catch (DMLException e)

          {
                     ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error occured'));
                      return null;
           }

         finally

         {
             document.body = null;
             document = new Document();
         }
 
    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Success.'));
    return null;
  }
 
}

 

Please help me to resolve this issue.

 

Bhawani SharmaBhawani Sharma
do you have any Apex Class named Document in your Salesforce apex classes list?
abhishekj25abhishekj25

Yes , I do have Document class already present

Bhawani SharmaBhawani Sharma
Delete your custom document class. There is already a standard object called document in Salesforce
sfdcfoxsfdcfox

You can use Schema.Document to create a new Document, since you have a Document class.