• ODCGI80101
  • NEWBIE
  • 0 Points
  • Member since 2011

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

We're trying to embrace best practices by externalizing some of our constants and configurations.  We've adopted Custom Settings in that vein.  Similiarly, we're looking to transition our unit tests to the newest api version (v24) since, by default, it isolates test data from existing data in Salesforce.  This is desirable since it will ensure our tests remain portable between different orgs -especially development sandboxes that don't have any data by default.

 

This is where we've hit a problem.  Using v24, none of our custom settings are available when the test starts.  Fine. Just like Accounts or Contacts, we'll create the data required by our tests.  So, I create the custom setting (in the example below, that's My_Custom_Setting__c).

 

Now the custom setting is available.  Then, when I test my actual code later in the test method, I make calls to My_Custom_Setting__c.getInstance(...), to get the custom setting.  Unfortunately, it returns null.  This is unfortunate since using getInstance(...) is the recommended way to access custom settings in code.  Why?  Because it's cached in the application cache and therefore very fast and efficient.

 

I'm going to guess that the below test fails because... when the application cache loads at the beginning of the test, there are no custom settings to cache.  Later on, when I insert the custom setting, the cache is not updated.  For this reason, furture calls to getInstance() don't return the custom setting I just inserted.  I would love it if someone could verify this.  I'm just guessing.

 

If that is the case, what's a developer to do? 

 

  1. Is there some way to refresh the application cache when custom settings are inserted?  I had hoped that inserting a custom setting the cache would be updated.
  2. Do I need to switch all of my code away from calling My_Custom_Setting__C.getInstance(...), to something like [Select ... from My_Custom_Setting_c Where Name = 'Standard Setting']?  If you run the below test, you'll see that querying for the custom setting using SOQL DOES return my just-inserted custom setting.  There's no caching there.
  3. Should I introduce a utility method that will need to be called whenever a piece of code requires my custom settings?  The method could check if it's running in a test context (Test.isRunningTest).  If so, it would do the SELECT, if not, it would call getInstance().

Thoughts?  Either I'm missing something, or this really is just a current difficiency in how Custom Settings are implemented.  I really want to migrate my tests to v24, but I would prefer not having to refactor non-test code to do it.

 

Andrew

 

//Test with api v24    
@isTest static void testAumConfig()
{
        My_Custom_Setting__c c = new My_Custom_Setting__c();
        c.Name = 'Standard Configuration';
        insert c;
       
        List<My_Custom_Setting__c> cs = [Select Id from My_Custom_Setting__c Where Name = 'Standard Configuration']; 
        System.assert(cs.size() == 1);
        
        c = My_Custom_Setting__c.getInstance('Standard Configuration');
        System.assert(c != null); //this fails.  It doesn't find the custom setting, even though I just inserted it above!!!
}

 

Is there a way to hide/change the sender's attached email which is the logged in user when sending a mass email?

 

Because what im doing is I set the senderDisplayName and Replyto to an Organization-Wide Email Addresses which only change the sender's name and the reply..

 

But when I test the Mass Email... still the logged in user's email is displayed.

 

I need help on this.. thx =D



generally we write a query in a trigger which will be counted and throws a goverer error  so my doubt is when we use salesforce standard methods likes maps and write the same code will the queries in the maps also get counted and throws a error. plz clarify me on this

HI,

 

How can we sync the picklist values with that of the values in other table.

 

Ex: I have a country field in the Account object which is a picklist. It contains all the country names

Now i have another object called country which has fields called country code and country name. The name field contains all the country names. 

 

Now how do i sync the values of the country field in Account object with the values of the country name field of the country object.

 

Thanks

I have an approval proccess I am developing in the sandbox. On approval it does a field update, this causes an After Update trigger to fire. 

 

The approval process works great if the approver does the approval within salesforce, from the home page. However, when the approver attempts to approve it from e-mail, an e-mail is returned stating:

 

'An error occurred and your workflow approval message was not processed. Please contact your system administrator.'

 

Looking in the debug log I see:

CODE_UNIT_STARTED|[EXTERNAL]|01qT00000000g70|QuoteName on Quote trigger event AfterUpdate for [0Q0T00000004b1y]

15:03:40.182 (182968000)|EXCEPTION_THROWN|[EXTERNAL]|System.ListException: Row with null Id at index: 0

 

There is one checkbox field update and If I remove the field update, it works from e-mail. At first I thought this was it, but then I removed the trigger and it also works from e-mail. I've commented out every piece of the trigger code, minus a one system.debug statement and still it fails.

 

 

The field I am updating had no field restrictions and the process works fine inside of Salesforce. Any idea what is happening?

 

Thanks

 

Ok, I've rebuilt the trigger in Salesforce, rather then eclipse. Its failing at:

 

for(Quote q: trigger.new){  

 

QuoteID = q.ID; 

QuoteOppID = q.OpportunityId;  

 

}

 

Does the trigger.new list not get populated when fired from the e-mail API?

Hello everybody, could you please help me?

 

There's a problem:

 

I'm trying to run QuickStartApiSample application (found code here http://www.salesforce.com/us/developer/docs/api/index.htm). So, I get the error mentioned in subject. What may be a root cause and how to solve it? Thanks.

  • April 29, 2011
  • Like
  • 0

Hello All

I have a trigger on quote after update and approval workflow that change quote status to approved or rejected

When i approve from application there is no issues

However when using email to approve i receive an error

 

12:20:57.352|CODE_UNIT_STARTED|[EXTERNAL]|01qP00000004FVf|Quote_afterUpdate on Quote trigger event AfterUpdate for [0Q0P000000007v1]
12:20:57.352|EXCEPTION_THROWN|[EXTERNAL]|System.ListException: Row with null Id at index: 0 12:20:57.352|CODE_UNIT_FINISHED|Quote_afterUpdate on Quote trigger event AfterUpdate for [0Q0P000000007v1]

 

Strange thing about that i am keeping to receive this error even i keep trigger blank

 

trigger Quote_afterUpdate on Quote (after update)
{

}

 

Any thoughts are welcome

Thanks