-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
6Questions
-
6Replies
PDF / test insanity?
I've just discovered that if a test calls code that generates a PDF, then the test always passes.
Generating a PDF cause code execution to fall into a black hole of success, which is a shame, because sometimes tests are supposed to fail.
Here's a test that passes:
private class KerryTest {
class MyException extends Exception {}
public static testMethod void thisIsCrazy() {
PageReference pdf = Page.ForgotPassword;
Blob pdfBody = pdf.getContentAsPDF();
throw new MyException('This test should fail!');
}
}
.... it really, really, shouldn't!
I know that the docs say I can't call "getContentAsPDF" in a test, which is itself ridiculous, but SURELY it should throw an error, or return an empty PDF, or SOMETHING -- not simply disappear into the ether?
Can somebody who knows something explain? I'd love to hear the justification for this behaviour.
I've just wasted an awful lot of time figuring out why my test wasn't failing, when I knew it should've been!
Thanks
Kerry
-
- kerryland6
- July 18, 2011
- Like
- 0
- Continue reading or reply
Too many Unknown Exceptions?
I'm noticing "Unknown Exception" appearing all over the place, in multiple Salesforce instances. Mostly since the new release has gone live.
Am I alone in seeing this?
I have a vision of a log file in the back of Salesforce somewhere that is filling disk with "Unknown Exception" messages, while teams of Salesforce developers stare in panic as the messages scroll past quickly.
Please can somebody tell me there are teams of Salesforce developers trying to kill these errors?
Thanks
Kerry
PS: "ErrorId if you contact support: 813317444-2484 (-426534673)"
-
- kerryland6
- June 20, 2011
- Like
- 0
- Continue reading or reply
Metadata api -- how read a profile's permissions?
How can I READ an existing profile's "ProfileObjectPermission" using the metadata api?
I can see that I can UPDATE it with code something like that shown below, but it's very hard to update a profile if I can't read it in the first place.
Do I really have to get it file the file-based api and parse the XML myself?
Thanks
Kerry
PS: Here's the code to update a profile -- but what does the code to read it look like?
// Set permissions for a table
ProfileObjectPermissions pop = new ProfileObjectPermissions();
pop.setAllowCreate(true);
...
pop.setTable("Sometable__c");
// Connect the permissions to a profile
-
- kerryland6
- June 13, 2011
- Like
- 0
- Continue reading or reply
Unable to delete Custom Field due to "Assignment Rules"
Hi Folks,
I'm trying to delete a custom field via the MetaData api:
-
- kerryland6
- June 11, 2011
- Like
- 0
- Continue reading or reply
IP Range restrictions not working?
Hi Folks,
Thanks
Kerry
-
- kerryland6
- May 11, 2011
- Like
- 0
- Continue reading or reply
soql "or" is broken?
Can anybody please explain why "or" dosn't behave as I expect in the following...?
1. Create an opportunity with a name of "Joe Bloggs"
then run this query:
select id, Account.LastName , Name
from Opportunity where Name= 'Joe Bloggs"
you will get one result
then run this query:
select id, Account.LastName , Name
from Opportunity where Name= 'Joe Bloggs'
or Account.Lastname = 'Bloggs'
you will get zero results.
I don't know that this Opportunity is not associated with an Account (which I assume is somehow related to the empty result), but can somebody provide a query that will work whether there is an account or not?
Thanks very much for your help -- this has driven me quite mad!
Kerry
-
- kerryland6
- September 13, 2007
- Like
- 0
- Continue reading or reply
PDF / test insanity?
I've just discovered that if a test calls code that generates a PDF, then the test always passes.
Generating a PDF cause code execution to fall into a black hole of success, which is a shame, because sometimes tests are supposed to fail.
Here's a test that passes:
private class KerryTest {
class MyException extends Exception {}
public static testMethod void thisIsCrazy() {
PageReference pdf = Page.ForgotPassword;
Blob pdfBody = pdf.getContentAsPDF();
throw new MyException('This test should fail!');
}
}
.... it really, really, shouldn't!
I know that the docs say I can't call "getContentAsPDF" in a test, which is itself ridiculous, but SURELY it should throw an error, or return an empty PDF, or SOMETHING -- not simply disappear into the ether?
Can somebody who knows something explain? I'd love to hear the justification for this behaviour.
I've just wasted an awful lot of time figuring out why my test wasn't failing, when I knew it should've been!
Thanks
Kerry
- kerryland6
- July 18, 2011
- Like
- 0
- Continue reading or reply
Metadata api -- how read a profile's permissions?
How can I READ an existing profile's "ProfileObjectPermission" using the metadata api?
I can see that I can UPDATE it with code something like that shown below, but it's very hard to update a profile if I can't read it in the first place.
Do I really have to get it file the file-based api and parse the XML myself?
Thanks
Kerry
PS: Here's the code to update a profile -- but what does the code to read it look like?
// Set permissions for a table
ProfileObjectPermissions pop = new ProfileObjectPermissions();
pop.setAllowCreate(true);
...
pop.setTable("Sometable__c");
// Connect the permissions to a profile
- kerryland6
- June 13, 2011
- Like
- 0
- Continue reading or reply
IP Range restrictions not working?
Hi Folks,
Thanks
Kerry
- kerryland6
- May 11, 2011
- Like
- 0
- Continue reading or reply
"Create New Lead" page in an iframe: javascript error
Hi,
I included the standard "create new lead" page in an iframe of my custom Visualpage (via apex:iframe). Unfortunately, in this context, typing in the lead input triggers lots of Javascript errors like the following:
Error: 'parentWindow.handleKeyDown' is null or not an object
I found out that it was because the Salesforce Javascript (in desktopCommon,js) can't initialize the "parentWindow" variable. As the domain of my custom page ("c.na7.visual.force.com") and the domain of the standard lead creation page ("na7.salesforce.com") are different, an "access denied" error prevents the inialization of 'parentWindow'.
Is there a general way to prevent/work-around this category of errors?
Is this behavior limited to the development environment or is it the same in production?
Thanks for the help.
Philippe
- viphe
- June 13, 2010
- Like
- 0
- Continue reading or reply
BUG: Force.com Migration Tool - "Cannot rename standard profile"
I'm trying to move a custom field from one sandbox into another using the Force.com Migration Tool, and getting a funky "Cannot rename standard profile" error.
Here's my package file which goes in the "$PROJECT_ROOT/unpackaged" folder:
<?xml version="1.0" encoding="UTF-8"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>*</members> <name>Profile</name> </types> <types> <members>Account.Test__c</members> <name>CustomField</name> </types> <version>18.0</version> </Package>
Here's my ant build.xml file which sits in the $PROJECT_ROOT folder:
<project name="Sample usage of Salesforce Ant tasks" default="test" basedir="." xmlns:sf="antlib:com.salesforce"> <property file="build.properties"/> <property environment="env"/> <target name="retrieveUnpackaged"> <mkdir dir="retrieveUnpackaged"/> <sf:retrieve username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" retrieveTarget="retrieveUnpackaged" unpackaged="unpackaged/package.xml"/> </target> <target name="deployUnpackaged"> <sf:deploy username="${sf.deploy.username}" password="${sf.deploy.password}" serverurl="${sf.deploy.serverurl}" deployRoot="retrieveUnpackaged"/> </target> </project>
This properties file all goes in the $PROJECT_ROOT folder:
# build.properties # sf.username = <username>@<org>.sandbox1 sf.password = <password> sf.serverurl = https://test.salesforce.com sf.deploy.username = <username>@<org>.sandbox2 sf.deploy.password = <password> sf.deploy.serverurl= https://test.salesforce.com
To run, execute the following two commands:
ant retrieveUnpackaged ant deployUnpackged
When I try to deploy to the second sandbox I am getting the following error:
Error: profiles/Guest License User.profile(Guest License User):Cannot rename standard profile
My package is pretty straightforward and I can't imagine what I might be doing to get this error. Any thoughts?
Thanks,
Greg
- glorge
- May 13, 2010
- Like
- 0
- Continue reading or reply
soql "or" is broken?
Can anybody please explain why "or" dosn't behave as I expect in the following...?
1. Create an opportunity with a name of "Joe Bloggs"
then run this query:
select id, Account.LastName , Name
from Opportunity where Name= 'Joe Bloggs"
you will get one result
then run this query:
select id, Account.LastName , Name
from Opportunity where Name= 'Joe Bloggs'
or Account.Lastname = 'Bloggs'
you will get zero results.
I don't know that this Opportunity is not associated with an Account (which I assume is somehow related to the empty result), but can somebody provide a query that will work whether there is an account or not?
Thanks very much for your help -- this has driven me quite mad!
Kerry
- kerryland6
- September 13, 2007
- Like
- 0
- Continue reading or reply