function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
wintamutewintamute 

Bug in Flex Toolkit, fix included

Hi,
the latest flex toolkit contains a bug when doing a DescribeLayout Call and the editLayoutSection contains only a single section. DescribeLayout throws a null-pointer error in this case.
Since the source is available, I did a quick fix so the maintainer of the toolkit can add it to the respository.

Code:
Index: /Users/andi/Documents/workspace33/Salesforce Flex sdk/src/com/salesforce/results/DescribeLayout.as
===================================================================
--- /Users/andi/Documents/workspace33/Salesforce Flex sdk/src/com/salesforce/results/DescribeLayout.as (revision 722)
+++ /Users/andi/Documents/workspace33/Salesforce Flex sdk/src/com/salesforce/results/DescribeLayout.as (working copy)
@@ -27,9 +27,8 @@
 */
 package com.salesforce.results
 {
+ import mx.collections.ArrayCollection;
  import mx.utils.ObjectProxy;
- import mx.collections.ArrayCollection;
- import com.salesforce.results.*;
   /**
    * Returned in the response to describeLayout(), contains detailed information on the custom or standard object page layout
    * 
@@ -51,9 +50,11 @@
      // one of detailLayoutSections, editLayoutSections, relatedList
      if (key == "detailLayoutSections" || key == "editLayoutSections") {
       this[key] = new ArrayCollection();
-      for (var i:int = 0;i<(val as ArrayCollection).length;i++) { 
-       this[key].addItem( new DescribeLayoutSection((val as ArrayCollection)[i]) );
-      }  
+      if(val is ArrayCollection) {
+       for (var i:int = 0;i<(val as ArrayCollection).length;i++) { 
+        this[key].addItem( new DescribeLayoutSection((val as ArrayCollection)[i]) );
+       }
+      } else this[key].addItem( new DescribeLayoutSection((val as ObjectProxy)));
      } else if (key == "relatedLists") {
       this[key] = new ArrayCollection();
       for (var i2:int = 0;i2<(val as ArrayCollection).length;i2++) { 

 cheers,
Andi

Ron HessRon Hess
nice, thanks!
wintamutewintamute
After a second look I noticed that the next few lines of code handling the relatedList part contains the same bug. So if you apply the patch, this should be fixed too.

Cheers,
Andi
DeanFDeanF
Hi Ron,

Did this fix ever get into the Toolkit?  I'm also getting an error for describeLayout when trying to get stage picklist values for a specific opportunity RecordType.  Here's the code:

Code:
    private function GetRTStages():void
    {                     
        apex.describeLayout("Opportunity", [RecordType],
              new AsyncResponder(GetRTStages_CB, genericFault));
    }

 And here's the error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at com.salesforce.results::DescribeLayout()[/home/jamesw/projects/mavericks/sdk/src/com/salesforce/results/DescribeLayout.as:54]
    at com.salesforce.results::DescribeLayoutResult()[/home/jamesw/projects/mavericks/sdk/src/com/salesforce/results/DescribeLayoutResult.as:71]
    at SalesForceResponder/result()[/home/jamesw/projects/mavericks/sdk/src/com/salesforce/Connection.as:1259]
...

Thanks,
Dean




Message Edited by DeanF on 11-18-2008 09:16 PM