2

I'm needing my account managers to be able to upload two separate images to the account object. I don't see that there are any 'file upload' field types in the field data-type selections and I don't want these to be 'attachments' and I don't want these to be rich text fields. I've successfully integrated the mkpartners 'photo uploader' app which does basically what I want except it only lets me add one image upload field. I need two. I'm willing to try making an visualforce page and component if that's the way to go, but I've never created one before. Is that the way to go? How to start? Am I creating new pages and components or editing existing ones?

0

There is an outline of a solution here with an example

Essentially:

  • Create an additional rich text field on your Account
  • Create a custom button that launches a VF page. Put the button on your page layout.

  • VF page prompts for the file using apex:inputFile

  • VF page Upload button is associated with a controller action method that does the DML. Two DML operations:

  • (1) Controller action method inserts the file to an SFDC Document object

  • (2) Controller then uses ID of inserted Document object to construct a string:

    String rtf = <img src="/servlet/servlet.FileDownload?file='+d.id+'" 
         width="xx" height="yy"></img>'
    
  • (2 cont'd) then places this into the Account custom field and does an update. Note that implicitly, the controller will have the ID of the Account so the update is very simple:

    update (new Account (id = theCtlr.getId(), photoField2__c = rtf));
    

Note this could also be done entirely using a custom button and Javascript + SFDC AJAX toolkit (or probably, Javascript Remoting or Javascript Remote objects). Basically, you need to get the image into a place where SFDC can display it. The Rich Text field provide a convenient way to do this.

Note also that there is the SFDC feature Social Accounts, Contacts, Leads which has to be enabled in Setup and allows the user to see the public pages of a company or person using Facebook, Twitter, Klout, and YouTube. This "might' obviate the need for a picture upload as you can see your business contacts water skiing or playing with their cats and that might be more informative :-)

  • Thanks for the writeup, @cropredy. I should have mentioned that my requirements are to do this without a rich text field as well. Ultimately I do not want anything but the url or filename of the file to be stored with the object, not the img tag. – Bagus Dot Org May 16 '16 at 14:20
  • @BagusDotOrg - how does the photo uploader app work? does it use RTF? where does it save the image? – cropredy May 16 '16 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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