• rm1
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 10
    Replies

With the Spring 13 updates to the PDF engine, our visualforce PDFs no longer render images correctly.  We reference static resources by their absolute url as follows:

 

 

<apex:page renderAs="PDF">
<!-- this is a dummy url to a static resource --> <img src="https://na7.salesforce.com/resource/1268256191000/MyImage" /> </apex:page>

 

(Yes I know we can use the $Resource syntax, but we've had issues with that in managed packages).

 

The above code results in a PDF that displays the "broken image" graphic.

 

I can also get it to work by disabling the PDF engine critical update for Spring 13.  This is only temporary, however, as the updated will get automatically applied.

 

Can the engine be fixed so that we don't have to change all of our code to use static resources?  Thanks.

 

 

 

 

  • February 20, 2013
  • Like
  • 0

I encountered some unexpected behavior with the save() method on the standard controller and just curious as to the reasoning behind it.

 

I have an instance of a StandardController for a new custom object.  Calling the save() method successfully inserts a new record for the custom object.  If you call save() again, it inserts another new record instead of updating the existing one in the controller's context.

 

Here's the basic code:

 

MyObject__c o = new MyObject__c();
ApexPages.StandardController sc = new ApexPages.StandardController(o);

// this successfully inserts a new record...

sc.save();

// this successfully returns the Id of the new record
// doesn't this mean that the record is in the controller's current context?

Id myId = sc.getId();

// shouldn't this update the record that is in the current context?
// it does not; it inserts a new record

sc.save();

 

Why doesn't the second call to save() update the record that was inserted in the first call to save()?   It seems to be holding on to the reference of the object that was passed into the constructor.  This would kind of make sense to me if the call to getId() returned null.  At least it would appear that the context of the controller is consistent.

  • November 05, 2012
  • Like
  • 0

I have a visualforce page that has a custom component with rendered=false.  In a different pageBlockSection, I have an inlineEditSupport component.


The problem is that when the page loads, it executes the constructor and methods of the custom component's controller.   I wouldn't expect it to do that since rendered=false.

 

If I remove the inlineEditSupport component and reload the page, it does not execute the custom component controller.

 

How can I prevent my custom component controller from executing while keeping the inlineEditSupport on the page? Rendered=false does not seem to work.

 

Here is the (simplified) code:

 

1. Custom Component Controller

public class componentController {
	public List<account> accounts{
		get{
			system.debug('in accounts getter');				
			return new List<account>();
		}
		set;
	}
	public componentController(){
		system.debug('in constructor');
	}
}

 

2. Custom Component

<apex:component controller="componentController">
	<apex:pageBlockSection >
	    <apex:pageBlockTable value="{!accounts}" var="a">
	    	<apex:column >
	        	<apex:outputField value="{!a.name}"/>
			</apex:column>
		</apex:pageBlockTable>
	</apex:pageBlockSection>
</apex:component>

 

3. Visualforce Page

<apex:page controller="myController" tabStyle="Account">
    <apex:pageBlock >
        <apex:form >
            <apex:pageBlockSection >
                <apex:outputField value="{!account.name}" />
                <apex:outputField value="{!account.NumberOfEmployees}" />
                <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection columns="1">
                <c:editMode rendered="false" />
            </apex:pageBlockSection>
        </apex:form>
    </apex:pageBlock>
</apex:page>

 

When the above vf page loads, the debug log will include the "in constructor" and "in accounts getter" statements.  

If I remove the inlineEditSupport from the page and refresh, the debug log will not include those statements.

 

Any ideas?

  • May 11, 2012
  • Like
  • 0

According to the VisualForce documentation here, you should be able to add a dynamic reference to a static resource.

The documentation provides this example:

 

"A very simple example of actual use on a page would be <apex:image value="{!$Resource[customLogo]}"/>, where you have a getCustomLogo method that returns the name of an image uploaded as a static resource."

 

This doesn't seem to work.

 

Here is my controller method:

public String getCustomLogo(){
return 'CompanyLogo';
}

 

and here is the line from my vf page:

<apex:image value="{!$Resource[CustomLogo]}"/>

 

I get the following error when trying to save the vf page:

 

Error: Syntax error. Found '$Resource'


How can I get this to work?

  • February 02, 2012
  • Like
  • 0

We have a class that we need to upgrade to api version 18.0 to be able to use the new AggregateResult object. Once we changed the version to 18.0, we got a bunch of 'Method does not exist or incorrect signature' errors.  The errors occurred both in the IDE and the UI.

 

We have a custom object that contains a number field named 'quantity'.  It has 2 decimal places.  The schema browser indicates that the field is a Double.  So we have a bunch of code similar to this that works fine prior to version 18: 

 

 

public void foo(){

MyCustomObject__c obj = [select id, quantity__c from MyCustomObject__c limit 1];

foo(obj.quantity__c);

}

public void foo(Double d){

// do something

}

 

After changing to version 18, we get the error 'Method does not exist or incorrect signature: foo(Decimal) '. Apparently, v18 treats 'quantity' as a Decimal instead of a Double. So we have to cast our field to a Double as follows: 

 

 

public void foo(){

MyCustomObject__c obj = [select id, quantity__c from MyCustomObject__c limit 1];

foo(Double.valueOf(obj.quantity__c));

}

 

1.) Is there any other solution for this?  Is there any documentation on this?

2.) Will the Spring 10 IDE schema browser indicate the correct data types - Decimal vs. Double?

Message Edited by rm1 on 03-05-2010 06:58 AM
Message Edited by rm1 on 03-05-2010 06:59 AM
  • March 05, 2010
  • Like
  • 0
I have been unable to deploy a project using the Migration Tool.  However, it deploys just fine using the Force.com IDE.  

The error reads: "Failed to process the request successfully. Cause(LIMIT_EXCEEDED): LIMIT_EXCEEDED: Too many files in deploy call, limit is: 1500"

I am using a very simple Migration Tool command:  

<sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" deployRoot="trunk/src"/>.

My question is, what is different between the IDE and the Migration Tool that would cause this error to occur?  I am deploying the same folder using the same manifest (package.xml) file.
  • October 28, 2009
  • Like
  • 0

Trying to use the migration tool/Ant to deploy an unmanaged project.  The first attempt failed and the error message read: LIMIT_EXCEEDED: Too many files in deploy call, limit is: 1500.  So I changed the manifest file (package.xml) so it only included Apex Classes as follows:

 

 

<?xml version="1.0" encoding="UTF-8"?>

<Package xmlns="http://soap.sforce.com/2006/04/metadata">

<types>

<members>*</members>

<name>ApexClass</name>

</types>

<version>15.0</version>

</Package>

 

And the ant script:

 

<sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" deployRoot="trunk/src" />

   

I got the same error.  I went to the 'src' folder (where the manifest files resides as well as the individual component subfolders i.e. 'classes', 'components', etc.) and deleted all of the folders except the 'classes' folder.  This time it worked.

 

So it appears that the migration tool is trying to deploy all of the components in the folder regardless of what is in the manifest file.  Is this a true statement or am I doing something wrong? 

 

Message Edited by rm1 on 10-28-2009 08:02 AM
  • October 27, 2009
  • Like
  • 0

SUMMARY
I have signed up for the Salesforce Partner Program and have created a managed app called ABC Company using my Partner Developer Edition account (dev org).

The app consists of one parent custom object (Project__c) and two child custom objects (Sent_item__c & Received_item__c).

I have a visualforce PDF page that displays the Project Summary with the Sent and Received related lists. For this VF PDF Page I have created an Apex Class that sorts/orders the list by Name ASC for Sent and Received Related Lists. I also have an apex test class with 100% code coverage.

The Generate Visualforce PDF Page works without any problems in my Partner Developer Edition account (dev org).

PROBLEM
After successful installation of my app on my Enterprise/Platform Edition account (Test Org) as a managed app I receive the following error when I try to generate the VF page:

common.apex.runtime.impl.ExecutionException: SObject row was retrieved via SOQL without querying the requested field:ecpfinal__Project__c.Name

(The error only occurs in my managed solution when installed on another Enterprise/Platform Edition account (Test Org))

Can you provide the necessary code to fix this error? Do I need to add additional code to the apex class?

VISUALFORCE PDF PAGE (Project_Summary)
<apex:page standardController="Project__c" sidebar="false" showHeader="false" renderAs="pdf" extensions="ProjectSummaryPDFController">
<hr></hr>
   <h3>PROJECT SUMMARY</h3>
<hr></hr>
 <table  style="width: 100%;">
<tr><td style="width: 25%;">Project Number:</td><td style="width: 75%;">{!Project__c.Name}</td></tr>
<tr><td style="width: 25%;">Project Name:</td><td style="width: 75%;">{!Project__c.Project_Name__c}</td></tr>
<tr><td style="width: 25%;">Contractor:</td><td style="width: 75%;">{!Project__c.Contractor__c}</td></tr>
 </table>
 <hr></hr>
   <b>SENT ITEMS</b>
<hr></hr>
<apex:dataTable value="{!cvSentItemLineItemsSorted}" var="item" border="1" cellpadding="3" width="100%" >
<apex:column >
<apex:facet name="header">Item Number</apex:facet>
<apex:outputText value="{!item.Name}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Description</apex:facet>
<apex:outputText value="{!item.Description__c}"/>
</apex:column>
 </apex:datatable>
<hr></hr>
   <b>RECIEVED ITEMS</b>
<hr></hr>
 <apex:dataTable value="{!cvReceivedItemLineItemsSorted}" var="item" border="1" cellpadding="3" width="100%" >
<apex:column >
<apex:facet name="header">Item Number</apex:facet>
<apex:outputText value="{!item.Name}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Description</apex:facet>
<apex:outputText value="{!item.Description__c}"/>
</apex:column>
 </apex:datatable>
  <hr></hr>
</apex:page>


APEX CLASS
public with sharing class ProjectSummaryPDFController {
       //set up the class variables we'll need to reference from VF page
       public List<Sent_item__c> cvSentItemLineItemsSorted {public get; private set;}
       public List<Received_item__c> cvReceivedItemLineItemsSorted {public get; private set;}
       
       //variable to hold current Project__c record
       private Project__c cvSelectedProject = null;
       
       //constructor
       public ProjectSummaryPDFController(ApexPages.StandardController pCntrllr)
       {
               // grab current Project__c record from the Standard Controller
               cvSelectedProject = (Project__c)pCntrllr.getRecord(); 
                       
               // build sorted List of Sent_item__c records for current Project__c
               cvSentItemLineItemsSorted = new List<Sent_item__c>();
               cvSentitemLineItemsSorted = 
                       [Select item.Name,
                               item.Description__c
                        From Sent_item__c item
                        Where item.Project_Number__c =: cvSelectedProject.id
                        ORDER BY item.Name ASC
                        limit 1000];
               
               // build sorted List of Received_item__c records for current Project__c
               cvReceivedItemLineItemsSorted = new List<Received_item__c>();
               cvReceivedItemLineItemsSorted = 
                       [Select item.Name, 
                               item.Description__c
                        From Received_item__c item
                        Where item.Project_Number__c =: cvSelectedProject.id
                        ORDER BY item.Name ASC
                        limit 1000];                         
       }     
}


APEX TEST CLASS
@isTest
private class testProjectSummaryPDFController {

   static testMethod void myUnitTest() {
        
       // make a valid Project__c record we will sent to PDF controller
       Project__c lvProject = makeValidProject();
       
       // make a Sent_item__c record for the project
       Sent_item__c lvSentItemObj = makeSentItemObj(lvProject);
       
       // make a Received_item__c record for the project
       Received_item__c lvReceivedItemObj = makeReceivedItemObj(lvProject);
       
       // first get the standard controller for my object and pass in the Project obj
       ApexPages.StandardController lvStdCntrllr = new ApexPages.standardController(lvProject);

       // now create an instance of my controller
       ProjectSummaryPDFController controller = new ProjectSummaryPDFController(lvStdCntrllr);

   }
       
static private Project__c makeValidProject() {
       // create Test Project record 
       Project__c lvProj = new Project__c();
       lvProj.Name = 'Name';
   lvProj.Project_name__c = 'Project Name';
       lvProj.Contractor__c = 'Contractor';
       
       insert lvProj; 
       
       return lvProj;
   }
   
   static private Sent_item__c makeSentItemObj(Project__c pProj) {
       Sent_Item__c lvObj = new Sent_Item__c();
       lvObj.Name = 'Name';
       lvObj.Description__c = 'Description';
       lvObj.Project_Number__c = pProj.Id;
       
       insert lvObj; 
       
       return lvObj;
   }
   
   static private Received_item__c makeReceivedItemObj(Project__c pProj) {
       Received_item__c lvObj = new Received_item__c();
       lvObj.Name = 'Name';
       lvObj.Description__c = 'Description';
       lvObj.Project_Number__c = pProj.Id;
       
       insert lvObj; 
       
       return lvObj;

   }
}

 

 

With the Spring 13 updates to the PDF engine, our visualforce PDFs no longer render images correctly.  We reference static resources by their absolute url as follows:

 

 

<apex:page renderAs="PDF">
<!-- this is a dummy url to a static resource --> <img src="https://na7.salesforce.com/resource/1268256191000/MyImage" /> </apex:page>

 

(Yes I know we can use the $Resource syntax, but we've had issues with that in managed packages).

 

The above code results in a PDF that displays the "broken image" graphic.

 

I can also get it to work by disabling the PDF engine critical update for Spring 13.  This is only temporary, however, as the updated will get automatically applied.

 

Can the engine be fixed so that we don't have to change all of our code to use static resources?  Thanks.

 

 

 

 

  • February 20, 2013
  • Like
  • 0

I have a visualforce page that has a custom component with rendered=false.  In a different pageBlockSection, I have an inlineEditSupport component.


The problem is that when the page loads, it executes the constructor and methods of the custom component's controller.   I wouldn't expect it to do that since rendered=false.

 

If I remove the inlineEditSupport component and reload the page, it does not execute the custom component controller.

 

How can I prevent my custom component controller from executing while keeping the inlineEditSupport on the page? Rendered=false does not seem to work.

 

Here is the (simplified) code:

 

1. Custom Component Controller

public class componentController {
	public List<account> accounts{
		get{
			system.debug('in accounts getter');				
			return new List<account>();
		}
		set;
	}
	public componentController(){
		system.debug('in constructor');
	}
}

 

2. Custom Component

<apex:component controller="componentController">
	<apex:pageBlockSection >
	    <apex:pageBlockTable value="{!accounts}" var="a">
	    	<apex:column >
	        	<apex:outputField value="{!a.name}"/>
			</apex:column>
		</apex:pageBlockTable>
	</apex:pageBlockSection>
</apex:component>

 

3. Visualforce Page

<apex:page controller="myController" tabStyle="Account">
    <apex:pageBlock >
        <apex:form >
            <apex:pageBlockSection >
                <apex:outputField value="{!account.name}" />
                <apex:outputField value="{!account.NumberOfEmployees}" />
                <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection columns="1">
                <c:editMode rendered="false" />
            </apex:pageBlockSection>
        </apex:form>
    </apex:pageBlock>
</apex:page>

 

When the above vf page loads, the debug log will include the "in constructor" and "in accounts getter" statements.  

If I remove the inlineEditSupport from the page and refresh, the debug log will not include those statements.

 

Any ideas?

  • May 11, 2012
  • Like
  • 0

According to the VisualForce documentation here, you should be able to add a dynamic reference to a static resource.

The documentation provides this example:

 

"A very simple example of actual use on a page would be <apex:image value="{!$Resource[customLogo]}"/>, where you have a getCustomLogo method that returns the name of an image uploaded as a static resource."

 

This doesn't seem to work.

 

Here is my controller method:

public String getCustomLogo(){
return 'CompanyLogo';
}

 

and here is the line from my vf page:

<apex:image value="{!$Resource[CustomLogo]}"/>

 

I get the following error when trying to save the vf page:

 

Error: Syntax error. Found '$Resource'


How can I get this to work?

  • February 02, 2012
  • Like
  • 0

will a custom component controller 's constructor get called even if the "Rendered" expression evaluates to "false"? Below is a visual force page that has two components. Only one of them is rendered depending on the user's Profile name:

 

<apex:page showHeader="true" sidebar="false" controller="SiteHeaderController" action="{!init}">
<apex:form >
User Profile:{!userProfile}<br/>
<apex:outputText value="SL Component" rendered="{!userProfile='Leader'}"/><br/>
<apex:outputText value="ZoneDiv Component" rendered="{!OR(userProfile='Division Manager',userProfile='Zone Manager')}"/><br/>
<apex:commandLink value="{!$Label.Earning_Opportunity}" action="{!showEarningOpportunity}" rerender="earningOpportunity" rendered="{!userProfile='Leader'}"/>
<apex:outputPanel id="earningOpportunity">
   	<apex:outputPanel rendered="{!showEarningOppty}">
    	<c:SalesLeaderEarningOpportunity rendered="{!userProfile='Leader'}"/>
    	<c:ZoneDivEarningOpportunity rendered="{!OR(userProfile='Division Manager',userProfile='Avon Zone Manager')}"/>
   	</apex:outputPanel>
</apex:outputPanel>                
</apex:form>

</apex:page>

 

ShowEarningOpportunity method is below:

 

public PageReference showEarningOpportunity(){
	this.showEarningOppty=true;
	return null;
}

 

 

When I executed the page and click on the "command link", both constructors are getting called. Am I missing something?

 

According to SFC documentation "values can be a primitive". An Integer is a primitive.

 

I am building a trigger that requires me to do a check on how many Circuits have already been defined. If the user is defining the first circuit, all fields are required. I had the count in a for loop and it works fine until I break the bulk trigger rules with Too many SOQL queries

 

Integer mycount  = [select count() from Circuit__c where Device__c = :circ.Device__c];

 

So I thought I would put the count in a Map and correlate it to an Id.

 

Map<Id, Integer> circCountMap = new Map<Id, Integer>
   ([SELECT count() FROM Circuit__c WHERE Device__c in:devIds]);

 

But when I try to save, I get an error

Error: Compile Error: Invalid initial type Integer for MAP:Id,String at line 13 column 35 

 

Why can't I do this? And does anybody have a suggestion for how I can get the counts so I can check each Circuit being inserted?

 

Thank you

We have a class that we need to upgrade to api version 18.0 to be able to use the new AggregateResult object. Once we changed the version to 18.0, we got a bunch of 'Method does not exist or incorrect signature' errors.  The errors occurred both in the IDE and the UI.

 

We have a custom object that contains a number field named 'quantity'.  It has 2 decimal places.  The schema browser indicates that the field is a Double.  So we have a bunch of code similar to this that works fine prior to version 18: 

 

 

public void foo(){

MyCustomObject__c obj = [select id, quantity__c from MyCustomObject__c limit 1];

foo(obj.quantity__c);

}

public void foo(Double d){

// do something

}

 

After changing to version 18, we get the error 'Method does not exist or incorrect signature: foo(Decimal) '. Apparently, v18 treats 'quantity' as a Decimal instead of a Double. So we have to cast our field to a Double as follows: 

 

 

public void foo(){

MyCustomObject__c obj = [select id, quantity__c from MyCustomObject__c limit 1];

foo(Double.valueOf(obj.quantity__c));

}

 

1.) Is there any other solution for this?  Is there any documentation on this?

2.) Will the Spring 10 IDE schema browser indicate the correct data types - Decimal vs. Double?

Message Edited by rm1 on 03-05-2010 06:58 AM
Message Edited by rm1 on 03-05-2010 06:59 AM
  • March 05, 2010
  • Like
  • 0

Hello All,

 

I want to create Reminder Functionality using Workflow and Trigger. I want to send reminder every day upto 10 Days to Registered user for login on their portal.

 

For that i created Trigger to send the SMS reminder and I created a time based workflow to run on Given date. But problem i am facing that it run only for first day.

 

Kindly  help.

 

 

We have a Batch Apex job class defined in our certified managed package.

 

It works in our dev org (no namespace), but when we deploy the code to the dev org WITH namespace or

install the package in a customer org, it does not. We have "Apex Notification Recipient" set and get all other error emails, but not this one.

 

Is there anything that must be set before we can execute a batch job in our package? User permissions, package permission or enable this in the org ?

 

Thanks.