• kerryland6
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 6
    Replies

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 

 

 

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)" 

 

 

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

 

Profile profile = new Profile();
profile.setFullName("Standard");
profile.setObjectPermissions(new ProfileObjectPermissions[]{pop});
// Update the profile
UpdateMetadata[] metadata = new UpdateMetadata[1];
metadata[0].setMetadata(profile);
metadataConnection.update(metadata);

 

 

Hi Folks,

 

I'm trying to delete a custom field via the MetaData api:

 

 

        CustomField cf = new CustomField();
        cf.setFullName("Account.SLA__c");
        AsyncResult[] result = metadataConnection.delete(new Metadata[]{cf});
.... but it fails with:
DEPENDENCY_EXISTS msg: This custom field is referenced elsewhere in salesforce.com. : Case Assignment Rules. This custom field is referenced elsewhere in salesforce.com. : Case Escalation Rules.
My question is: How can I delete "Case Assignment Rules" and "Case Escalation Rules" via an API?
Thanks heaps!
Kery

 

Hi Folks,

 

 

I have a public 'site' that works fine until I turn on IP Range restrictions. This problem only exists in production. Our 'sandbox' instances work fine with IP Range restrictions enabled.
Here is a step-by-step explanation of how I can reproduce the problem:
1. Visit our public website, with no IP-Range security turned on:
2. See that we get XML returned correctly (this works best in Firefox, btw -- in Chrome you will see a blank page, and have to 'view source')
3. Restrict access to our site by performing the following steps:
Setup | Develop | Sites 
Click 'Site Label'
Click "Public Access Settings"
Click "Login IP Ranges"
Click "New"
Enter IP range xxx.xx.xx.xxx to xxx.xx.xx.xxx (which is our public ip address, as verified by whatismyip.com)
4. Wait for a few moments -- the change seems to take a little while to take effect
5. Visit our public website, now with IP-Range security turned on:
6. Instead of the same XML I saw in step 2 I instead see:
      Authorization Required
      We're sorry, you've attempted to access something you're not authorised to view.
If I perform exactly these steps in our Sandbox it works fine -- step 6 displays the expected XML.
Note also that no errors are reported in the debug logs when I perform step 5.
Am I missing something? I've really got no idea where to look next. Salesforce support suggested that I "remove the settings first from the Sandbox since it might be conflicting with the Production environment", so I'm hoping 
for a more useful response here :-)

 

Thanks

Kerry

Hi Folks,

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

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 

 

 

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

 

Profile profile = new Profile();
profile.setFullName("Standard");
profile.setObjectPermissions(new ProfileObjectPermissions[]{pop});
// Update the profile
UpdateMetadata[] metadata = new UpdateMetadata[1];
metadata[0].setMetadata(profile);
metadataConnection.update(metadata);

 

 

Hi Folks,

 

 

I have a public 'site' that works fine until I turn on IP Range restrictions. This problem only exists in production. Our 'sandbox' instances work fine with IP Range restrictions enabled.
Here is a step-by-step explanation of how I can reproduce the problem:
1. Visit our public website, with no IP-Range security turned on:
2. See that we get XML returned correctly (this works best in Firefox, btw -- in Chrome you will see a blank page, and have to 'view source')
3. Restrict access to our site by performing the following steps:
Setup | Develop | Sites 
Click 'Site Label'
Click "Public Access Settings"
Click "Login IP Ranges"
Click "New"
Enter IP range xxx.xx.xx.xxx to xxx.xx.xx.xxx (which is our public ip address, as verified by whatismyip.com)
4. Wait for a few moments -- the change seems to take a little while to take effect
5. Visit our public website, now with IP-Range security turned on:
6. Instead of the same XML I saw in step 2 I instead see:
      Authorization Required
      We're sorry, you've attempted to access something you're not authorised to view.
If I perform exactly these steps in our Sandbox it works fine -- step 6 displays the expected XML.
Note also that no errors are reported in the debug logs when I perform step 5.
Am I missing something? I've really got no idea where to look next. Salesforce support suggested that I "remove the settings first from the Sandbox since it might be conflicting with the Production environment", so I'm hoping 
for a more useful response here :-)

 

Thanks

Kerry

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

  • June 13, 2010
  • Like
  • 0

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

Hi Folks,

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