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
Ashmi PatelAshmi Patel 

Compile Error: Variable does not exist: DocumentUtil

i got this error need help...
Here is the Apex Class

public class FileUploadController{
public Document document {get; set;}
public String url {get; set;}
public boolean hasImage {get; set;}
public static final String hasImage;
public static final String document;

public static void FileUpload()
    {
        hasImage = false;
        document = new document();
    }

public PageReference doUpload()
    {
if (document.body != null)
{
     System.debug('@@@@@@@@ document:' + document.name);
     if (document.name != null)
     {
         System.debug('@@@@@@@@ doSave');
         Document d = document;
         System.debug(document);
         System.debug('@@@@@@@@ document name: '+d.name);
         System.debug(d);
         d.folderid = UserInfo.getUserId(); //store in Personal Documents
         System.debug('@@@@@@@@ document folder id: '+d.folderid);
         d.IsPublic = true;
        try
        {
            insert d;
            url = DocumentUtil.getInstance().getURL(d);
            hasImage = true;
        }
        catch (Exception e)
        {
            ApexPages.addMessages(e);
            url = '';
        }
        d.body = null;
        System.debug('@@@@@@@@ document object id: '+d.id);
        String url = DocumentUtil.getInstance(d).getURL();
        System.debug('######## document content type: '+d.type);
    }
 }
     PageReference page = new PageReference('/apex/FileUpload');
     return page;

    }

/*  static testmethod void testFileUpload()
    {
        FileUpload fu = new FileUpload();
        fu.doUpload();
        fu.document.Name = 'test1';
        fu.document.Body = Blob.valueOf('test1');
        fu.doUpload();
    } */

 }


 
Shun KosakaShun Kosaka
Hi,
I guess DocumentUtil is not standard class. Create a class named DocumentUtil in your org by below code.
https://github.com/JyotiC/VNovaTrial/blob/master/Villanova_Dev1/src/classes/DocumentUtil.cls
Ashmi PatelAshmi Patel
Compile Error: Variable does not exist: SiteImageBrowser.isImage
got this error
Shun KosakaShun Kosaka

There seem to be other dependencies.
https://github.com/JyotiC/VNovaTrial/tree/master/Villanova_Dev1/src/classes 

1. Remove getURL and getURL(d) method from DocumentUtil
2. Create new classes clsConstants and ImageFile from above resource. (modify boolean value depending on your org and remove testmethod from ImageFile)
3. Create new class SiteImageBrowser without consturctor and testmethod (to line 7 and } )
https://github.com/JyotiC/VNovaTrial/blob/master/Villanova_Dev1/src/classes/SiteImageBrowser.cls
4. Paste getURL and getURL(d) method again in DocumentUtil (modify instance like na6 or cs1 depending on your org)
5. Paste constructor in SiteImageBroser class
6. Rename String hasImage and Document from FileUploadController because they duplicates name of other boolean variable
7. Rename "public static void FileUpload()" to "public FileUploadController()"

Ashmi PatelAshmi Patel
thnkuu @ shun kosaka
but i did not get uh