• Benjamin Bolopue
  • NEWBIE
  • 10 Points
  • Member since 2014
  • Salesforce Admin
  • Quanex Building Products


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 13
    Replies
My requirements are to
  • Incorporate a VF Page into the Case Object where Users could upload a single image
  • Have that single image stored as an Attachment for that Case
  • Renaming that Attachment 'CasePhoto1.jpg'
  • Extract that Attachment's ID and insert it into a custom field named CasePhoto1ID__c
So far, I've figured out everything but the extraction of the Attachment's ID. Here's what I have so far. Can anybody help me add the last piece of the puzzle (extracting the Attachment's ID and inserting it into CasePhoto1ID__c.

Here's the Controller:
public with sharing class CasePhotoUploadController1 {

    Private Static FINAL String fixedFileName = 'CasePhoto1.jpg';

    public boolean displaying { get; set; }
    public Case pageCase;
    public Blob casePicFile { get; set; }
    public Id currentPicture { get; set; }
    
    /** Constructor, grab record, and check/load an existing photo */
    public CasePhotoUploadController1(ApexPages.StandardController controller) {
        pageCase = (Case)controller.getRecord();
        
        List<attachment> currentPictures = [SELECT Id FROM Attachment WHERE parentId = :pageCase.Id AND name = :fixedFileName LIMIT 1];
        if(currentPictures.size() != 0) {
            currentPicture = currentPictures.get(0).Id;
        }
        
        displaying = true;
    }

    /** toggle switches between the photo display and photo upload form */
    public void toggle() {
        displaying = !displaying;
    }
    
    /** saveFile clears any existing (secondary) Case picture, retrieves the data from the form, and saves it under the relevant filename*/
    Public Pagereference saveFile() {

        // first, we cannot have any conflicting files
        List<attachment> savedPicture = [SELECT Id, name, body FROM Attachment WHERE parentId = :pageCase.Id AND name = :fixedFileName];
        if(savedPicture.size() > 0) {
            delete savedPicture;
        }
       
        // Now, the new blob is saved
        Attachment a = new Attachment(parentId = pageCase.Id, name = fixedFileName, body = casePicFile);
        insert a;
        
        currentPicture = a.Id;
        
        displaying = true;
        return null;
    }
  }

VF Page
<apex:page standardController="Case" extensions="CasePhotoUploadController1" showHeader="false" standardStyleSheets="true" sidebar="false">

<apex:form id="contentForm">
<div style="height:170px;">
    <apex:pageBlock mode="edit">
    
        <apex:pageblocksection columns="1" rendered="{!displaying}">
            <apex:image height="150" value="{!URLFOR($Action.Attachment.Download, currentPicture)}" rendered="{!currentPicture != null}"/>
            <apex:outputPanel rendered="{!currentPicture == null}"><em>No picture currently available</em></apex:outputPanel>
        </apex:pageblocksection>
        
        <apex:pageblocksection columns="1" rendered="{! !displaying}">
            <p>Use the button to below to select a new file and then press "Save"</p>
            <apex:inputFile value="{!profilePicFile}" />
            <p>Or press Cancel to return.</p>
        </apex:pageBlockSection>
        
    </apex:pageBlock>
</div>
    <apex:commandButton value="Upload new photo" action="{!toggle}" rerender="contentForm" rendered="{!displaying && currentPicture!=null}"/>
    <apex:commandButton value="Upload photo" action="{!toggle}" rerender="contentForm" rendered="{!displaying && currentPicture==null}"/>
    <apex:commandButton value="Cancel" action="{!toggle}" rendered="{! !displaying}"/>
    <apex:commandButton value="Save" action="{!saveFile}" rendered="{! !displaying}"/>
</apex:form>
  
</apex:page>

Any help would be much appreciated!

Thanks,
Ben

 
We're attempting to generate documents (PDFs) via Visualforce. Everything is generating exactly as expected except for images. Our images are being pulled from an external server and there's a redirect involved. Salesforce doesn't seem to like this re-direct.

Once PDF generation is initiated, linked-to images are pulled in via a URL stored in a text field. For security reasons, the URL stored in the Record's text field is re-directed to a secure server where the image files are actually stored. This re-direct is keeping images from being shown inthe PDFs we generate. A "Broken Link" icon shows where images should be.

This issue doesn't exist until PDFs are generated. When viewing the documents as VF pages, the images are rendered using the re-directed URLs without issue.

Can anyone offer insight as to why the re-direct is problematic or how to get around this issue?

Thanks,
Ben
Hello All,
Understanding full well that back in February, a similar question was posted by DannyTK, (https://developer.salesforce.com/forums/?id=906F0000000Abrg#!/feedtype=SINGLE_QUESTION_SEARCH_RESULT&id=906F0000000AyhxIAC" target="_blank) My scenario is slightly different, and I'm no developer. Any insight the community has to offer would be greatly appreciated! Here are the details:

1.) I'm working on a project that requires my Users be able to update a Lookup field (Owner__c) via a picklist selection.
2.) I have a simple formula field (Re_Assigned_To_ID__c) that produces a User ID based on the selection made via item 1's picklist.
3.) Owner__c and Re-Assigned_To_ID__c are custom fields on a custom object named NPS_Survey__c
4.) I think (please correct me if I'm wrong!) I need a trigger that fires when Re_Assigned_To_ID__c is changed and uses Re_Assigned_To_ID__c's value ( a User's ID) to update the Owner__c (Lookup field) value. 

Thanks for your time!

Ben
Scenario:
I'm creating a VF Page in order to display multiple Report Charts on one of our Account Page Layouts. 

Problem:
While using lines of code (like the following) to generate the charts is pretty straightforward, my scenario requires multiple filters and "OR" logic. As best I can tell... Adding more than one set of filter criteria always results in "AND"ing them together.

Report Chart Code Example:  
<analytics:reportChart reportId="00O13000008TY8B" size="tiny" filter="{column:'Account.Name', operator:'equals', value:'{!Account.Name}'}"> </analytics:reportChart>

Question:
How would I go about adding multiple filters that are "OR"ed together? I can't find any documentation on adding filter logic to Report Charts included on VF pages.

Thanks,
Ben
I need to insert a Report chart into a VisualForce page on a Custom Object named "Visit Preparation". Simple enough...

Where I'm struggling... I need to filter the Report's chart using the ID of the Account associated (via lookup relationship) with Visit Preparation Records.

I've created a field that pulls the associated Account's ID named "Salesforce_ID__c".

How do I filter the inserted Report Chart's data by the ID shown in the Salesforce_ID__c field?

Thanks in advance!
Is there a way to create a Visual Force component that counts the number of Accounts that are smaller/larger than the Account Record it's displayed on?

Thanks,
Ben
I’ve been tasked with automatically ranking our Accounts based on the qty listed in a "projected volume" field. Any suggestions?

Thanks in advance!

Ben
My requirements are to
  • Incorporate a VF Page into the Case Object where Users could upload a single image
  • Have that single image stored as an Attachment for that Case
  • Renaming that Attachment 'CasePhoto1.jpg'
  • Extract that Attachment's ID and insert it into a custom field named CasePhoto1ID__c
So far, I've figured out everything but the extraction of the Attachment's ID. Here's what I have so far. Can anybody help me add the last piece of the puzzle (extracting the Attachment's ID and inserting it into CasePhoto1ID__c.

Here's the Controller:
public with sharing class CasePhotoUploadController1 {

    Private Static FINAL String fixedFileName = 'CasePhoto1.jpg';

    public boolean displaying { get; set; }
    public Case pageCase;
    public Blob casePicFile { get; set; }
    public Id currentPicture { get; set; }
    
    /** Constructor, grab record, and check/load an existing photo */
    public CasePhotoUploadController1(ApexPages.StandardController controller) {
        pageCase = (Case)controller.getRecord();
        
        List<attachment> currentPictures = [SELECT Id FROM Attachment WHERE parentId = :pageCase.Id AND name = :fixedFileName LIMIT 1];
        if(currentPictures.size() != 0) {
            currentPicture = currentPictures.get(0).Id;
        }
        
        displaying = true;
    }

    /** toggle switches between the photo display and photo upload form */
    public void toggle() {
        displaying = !displaying;
    }
    
    /** saveFile clears any existing (secondary) Case picture, retrieves the data from the form, and saves it under the relevant filename*/
    Public Pagereference saveFile() {

        // first, we cannot have any conflicting files
        List<attachment> savedPicture = [SELECT Id, name, body FROM Attachment WHERE parentId = :pageCase.Id AND name = :fixedFileName];
        if(savedPicture.size() > 0) {
            delete savedPicture;
        }
       
        // Now, the new blob is saved
        Attachment a = new Attachment(parentId = pageCase.Id, name = fixedFileName, body = casePicFile);
        insert a;
        
        currentPicture = a.Id;
        
        displaying = true;
        return null;
    }
  }

VF Page
<apex:page standardController="Case" extensions="CasePhotoUploadController1" showHeader="false" standardStyleSheets="true" sidebar="false">

<apex:form id="contentForm">
<div style="height:170px;">
    <apex:pageBlock mode="edit">
    
        <apex:pageblocksection columns="1" rendered="{!displaying}">
            <apex:image height="150" value="{!URLFOR($Action.Attachment.Download, currentPicture)}" rendered="{!currentPicture != null}"/>
            <apex:outputPanel rendered="{!currentPicture == null}"><em>No picture currently available</em></apex:outputPanel>
        </apex:pageblocksection>
        
        <apex:pageblocksection columns="1" rendered="{! !displaying}">
            <p>Use the button to below to select a new file and then press "Save"</p>
            <apex:inputFile value="{!profilePicFile}" />
            <p>Or press Cancel to return.</p>
        </apex:pageBlockSection>
        
    </apex:pageBlock>
</div>
    <apex:commandButton value="Upload new photo" action="{!toggle}" rerender="contentForm" rendered="{!displaying && currentPicture!=null}"/>
    <apex:commandButton value="Upload photo" action="{!toggle}" rerender="contentForm" rendered="{!displaying && currentPicture==null}"/>
    <apex:commandButton value="Cancel" action="{!toggle}" rendered="{! !displaying}"/>
    <apex:commandButton value="Save" action="{!saveFile}" rendered="{! !displaying}"/>
</apex:form>
  
</apex:page>

Any help would be much appreciated!

Thanks,
Ben

 
We're attempting to generate documents (PDFs) via Visualforce. Everything is generating exactly as expected except for images. Our images are being pulled from an external server and there's a redirect involved. Salesforce doesn't seem to like this re-direct.

Once PDF generation is initiated, linked-to images are pulled in via a URL stored in a text field. For security reasons, the URL stored in the Record's text field is re-directed to a secure server where the image files are actually stored. This re-direct is keeping images from being shown inthe PDFs we generate. A "Broken Link" icon shows where images should be.

This issue doesn't exist until PDFs are generated. When viewing the documents as VF pages, the images are rendered using the re-directed URLs without issue.

Can anyone offer insight as to why the re-direct is problematic or how to get around this issue?

Thanks,
Ben
I need to insert a Report chart into a VisualForce page on a Custom Object named "Visit Preparation". Simple enough...

Where I'm struggling... I need to filter the Report's chart using the ID of the Account associated (via lookup relationship) with Visit Preparation Records.

I've created a field that pulls the associated Account's ID named "Salesforce_ID__c".

How do I filter the inserted Report Chart's data by the ID shown in the Salesforce_ID__c field?

Thanks in advance!
Is there a way to create a Visual Force component that counts the number of Accounts that are smaller/larger than the Account Record it's displayed on?

Thanks,
Ben
I’ve been tasked with automatically ranking our Accounts based on the qty listed in a "projected volume" field. Any suggestions?

Thanks in advance!

Ben