• Paul - Salesbri
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 14
    Replies
Hi,

I have a very odd problem indeed.  I am trying to build a nested Map of Contact details.  I need to loop through each Contact record, create a map with the values, Email, AccountId and ContactId and then add this to another map with a integer key.  All pretty straight forward, yet when I try and access the parent map and display the child entries I get the message 'Already Output' and when I loop through the Parent Map object values are all the same, yet when outputting the items in the map after insertion they show the expected values.

The reason I need to use a Map as opposed to a SELECT clause is that we already hold the items in memory and we're trying to limit the number of queries as we're at 11 already.

Code below:
Code:
 private static testMethod void testManualConvertLead()
 {
  Account[] createAccount = new Account[]
   {
    new Account(Name = 'TestLead1'),
    new Account(Name = 'TestLead1'),
    new Account(Name = 'TestLead1')
   };
   
  insert createAccount;

  Contact[] createContact = new Contact[]
   {
    new Contact(FirstName = 'Test', LastName = 'Last 1', Email = 'test1@bob.com', AccountId = createAccount[0].Id),
    new Contact(FirstName = 'Test', LastName = 'Last 2', Email = 'test2@bob.com', AccountId = createAccount[1].Id),
    new Contact(FirstName = 'Test', LastName = 'Last 3', Email = 'test3@bob.com', AccountId = createAccount[2].Id)
   };
   
  insert createContact; 

  Map<Integer,Map<String,String>> contactDetails = new Map<Integer,Map<String,String>>();
  Map<String,String> contactDetail = new Map<String,String>();
  system.debug(createContact.size()); 
  for(integer n = 0; n < createContact.size() ; n++)
  {
   system.debug('-');
   system.debug(createContact[n].Id);
   system.debug(createContact[n].AccountId);
   system.debug(createContact[n].Email);
   
   contactDetail.put('ContactId',createContact[n].Id);
   contactDetail.put('AccountId',createContact[n].AccountId);
   contactDetail.put('Email',createContact[n].Email);
   
   system.debug(contactDetail);   
   system.debug(n);
   
   contactDetails.put(n,contactDetail);
   system.debug(contactDetails.get(n));
   system.debug('-');
  }
  
  system.debug(contactDetails);
  
  for(integer p = 0 ; p < contactDetails.size() ; p++)
  {
   system.debug(contactDetails.get(p));
  }
 }

 

Hi All

I'm trying to upload a package to the appexchange that contains an APEX class that has a @future(callout=true) note, the tests all execute fine (apart from the @future as they are not supported) and the code functions without error in the development environment yet when I try to upload I get this error in the debug log.

'Future method cannot be called from a future method: getLicenceKey(String, String)'

It's all very strange, so hopefull someone can help.

Cheers

Paul
Hi All,

Amazing how the simplest things are the most challenging.

I'm trying to convert a string of false / true to a boolean, I've tried the code below and I keep getting 'System.TypeException: Invalid boolean: true'.  I have no idea why, as my other type conversions are working fine.

Code below is an extract of a test function, the actual usage is in a much larger method!  Please help!

public class convertToBool
{
    public static void testConvert()
    {
        Integer i;
        String s;
        s='10';
        i=integer.valueof(s);
        system.assertEquals(10,i); //this test passes
   
        string asdf = 'true';
        //boolean bob = boolean.valueof(asdf);
        system.debug(Boolean.valueOf(asdf));
    }
   

    public static testMethod void testConvertToBool()
    {
        testConvert();
    }
}
Using the outputField tag causes css styles to be ignored for that page. (This only happens for me when rendering to pdf)

The following code works correctly and css styles are parsed:
Code:
<apex:page controller="PrintMfgClass" renderas="pdf" showheader="false">
<style type="text/css">
@page{
 size: landscape;

@top-right{content:"Page " counter(page);
}
}
.big4 {font-size: 32px}
</style>
<p class="big4">Should be Big </p>
<apex:outputText value="{!FirstMfgStyle.Description__c}" />
</apex:page>

 
this code ignores css styles (layout is portrait, no number and "Should be Big" is normal size)
Code:
<apex:page controller="PrintMfgClass" renderas="pdf" showheader="false">
<style type="text/css">
@page{
size: landscape;

@top-right{content:"Page " counter(page);
}
}
.big4 {font-size: 32px}
</style>
<p class="big4">Should be Big </p>
<apex:outputField value="{!FirstMfgStyle.Description__c}" />
</apex:page>
 
Is this a known bug with the outputfield tag? Is there a workaround?
I've set up a situation where:
* changing a field triggers a time-based WF rule, which after an hour
* changes another field on the same object, which
* triggers an apex trigger, which
* changes yet another field

This works fine in general, for small record sets.

However, I just tested it in bulk (by making that first field update to a bunch of records at once), and it failed governor limits (too many DML rows).  I didn't expect this, because as far as we the developers can tell, each record is put on the time-workflow queue separately.  However, it appears that since I triggered the time WF at the same time for all the records, they all came off the queue at the same time and were batched for trigger processing.

Specifcally, I tried this operation w/ 380 records.  It looks like it did one batch of 200 and one batch of 180.  So exactly what you'd expect if there was no time WF involved.

But the weird part is: it seems to have batched the records, but not scaled the governor limits to account for it.  So in my batch of 200, I got an error message saying: too many DML rows 201.  But for a trigger operating on 200 records, the limit for DML rows should be 20k.  And I got 200 separate email error messages delivered. So it seems to be treating it as partly a batch, but partly 200 separate operations.

Can someone help with this?  Is this how it's meant to work?

Thanks much!
  • November 06, 2008
  • Like
  • 0
Hi All

I'm trying to upload a package to the appexchange that contains an APEX class that has a @future(callout=true) note, the tests all execute fine (apart from the @future as they are not supported) and the code functions without error in the development environment yet when I try to upload I get this error in the debug log.

'Future method cannot be called from a future method: getLicenceKey(String, String)'

It's all very strange, so hopefull someone can help.

Cheers

Paul
Hi All,

Amazing how the simplest things are the most challenging.

I'm trying to convert a string of false / true to a boolean, I've tried the code below and I keep getting 'System.TypeException: Invalid boolean: true'.  I have no idea why, as my other type conversions are working fine.

Code below is an extract of a test function, the actual usage is in a much larger method!  Please help!

public class convertToBool
{
    public static void testConvert()
    {
        Integer i;
        String s;
        s='10';
        i=integer.valueof(s);
        system.assertEquals(10,i); //this test passes
   
        string asdf = 'true';
        //boolean bob = boolean.valueof(asdf);
        system.debug(Boolean.valueOf(asdf));
    }
   

    public static testMethod void testConvertToBool()
    {
        testConvert();
    }
}
BrainEngine has just released the first version our Developer Workbench product. Features Include:
  • Ability to work simultaneously with several queries in separate windows
  • Editing capabilities: snippets, intellisense, syntax highlight, code folding
  • Export data to 8 popular formats: MS Excel, MS Access, MS Word, RTF, HTML, PDF, XML, and CSV
  • Import data from MS Excel
  • Generate reports on object definition, object schema and relationships
  • Generate object ER Diagrams
  • View Page Layout Definitions
  • Outbound Messaging Support
  • Enhanced HTML Page Editor
The Workbench comes in two different versions. The Community Edition (freeware) and the Professional Edition (Community Edition + Priority Support). Click here for more details
Hi All,

I am having a few issues trying to migrate custom objects from one org to another using the Eclipse IDE.

The objects do not exist on the environment I am trying to create them on. I notice that in the metadata, field names are detailed under the <fullName> element.  The problem I have is caused by some fields referencing other fields by their API name, which includes any namespace references.  However, in the metadata, the field definition doesn't list the API name so I am getting errors stating that the fields do not exist.

An example is below.  In red, you can see the field being referenced  is the full API name, however the definition for this field in the metadata doesn't use the API name.

Is this problem caused by using a namespace prefix?

Hope someone can help out!

Cheers,
Andrew

<fields>
        <fullName>Programme_RAG_Flag__c</fullName>
        <formula>IMAGE(
CASE
(manage__Programme_Status__c  ,
&quot;Blue&quot;, &quot;servlet/servlet.FileDownload?file=01540000000MbVj&quot;,
&quot;Green&quot;, &quot;/img/samples/flag_green.gif&quot;,
&quot;Amber&quot;, &quot;/img/samples/flag_yellow.gif&quot;,
&quot;Red&quot;, &quot;/img/samples/flag_red.gif&quot;,&quot;/s.gif&quot;
),
&quot;priority flag&quot;)</formula>
        <formulaTreatBlanksAs>BlankAsZero</formulaTreatBlanksAs>
        <label>Programme RAG Flag</label>
        <type>Text</type>
    </fields>