• DManelski
  • NEWBIE
  • 50 Points
  • Member since 2008

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 42
    Replies

Hi,

 

I am new to visualforce development. I am having an issue with fetching more than 1000 records from database to be displayed on a visualforce page.

 

I am getting the exception 'System.Exception: collection exceeds maximum size: 1001'

 

Can anyone help me?

Here is the code snippet:

 

public void getProductLists(){
//Each iteration of the outer for loop fetches 1000 records....There are about 10K records in total
for(List<PricebookEntry> allProducts : [Select p.Product2Id,p.Product2.Name,p.Product2.Description,p.Product2.Family From PricebookEntry p where p.Pricebook2Id =: chObj.PriceBook_Id__c])
{

for(PricebookEntry p:allProductsList){
if(recommendedProductMap.containsKey(p.Product2Id) ){
recommendedProductsList.add(new sProduct(p));
}
else{
//Now after filtering, this list should contain some 5K+ records.But I get the exception 'System.Exception: collection exceeds maximum size: 1001'
allOtherProductsList.add(new sProduct(p));

}

}

}

 

 

 

Hi there. I have written a controller extension that works a charm.

In one of my methods (that is invoked from the constructor when the page loads),

I do a getDescribe() to get the picklist values for a field. Nothing strange so far... 

 

 

//mandatory controller extension constructor... public StockOrderPageExtension(ApexPages.StandardController stdController) { this.contextStockOrder = (Stock_Order__c) stdController.getRecord(); queryForProductCategories(); showSaveMessage = false; } //This method queries for all the current Bausch product Categories... public void queryForProductCategories() { //Get the Field Token Schema.SObjectField sf = Stock_Product__c.Product_Type__c; //Call describe on the Field Token Schema.DescribeFieldResult sdfr = sf.getDescribe(); //add the defaul sf selectlist value to //the SelectOption list... allProductCategories.add(new SelectOption('null','--None--')); for( Schema.PicklistEntry plentry : sdfr.getPicklistValues()) allProductCategories.add(new SelectOption(plentry.getValue(),plentry.getLabel())); }

Ok. So....

In my test method I have created 1 dummy Stock_Product__c records and given it a Product_Type__c value.

 

 

//Create some Product Categories Stock_Product__c stockProduct = new Stock_Product__c(name='mac', Product_Type__c='Notebook');

 

Fine. So..... 

Now I create an instance of my controller extension.

This invokes the method queryForProductCategories().

I then do a System.debug() on the allProductCategories List in my test method (which is a list of SelectOptions)

 

System.debug('****** ALL PRODUCT CATEGORIES ARE: ' + extensionController.getAllProductCategories());

 But....

I do not see the stock product I created in my test method above.

How on earth can I get around this? I really cannot see a path.

It makes sense in one degree that when teh method queryForProductCategories is invoked (from the test class),

it will get all the picklist values that are committed to the database. 

Has anyone got any help or suggestions? Greatly appreciated.

 

Regards


 

 

 

 

 

Hello,

 

I'm running into a problem rendering a VF page as a PDF and attaching it to an opportunity record and Single Email Message. The code executes correctly but I get 4 email messages and 4 PDF attachments, none of which actually open in a PDF reader.  I'll be glad to post my code but I wanted to find out if anyone else has run into this issue.

 

Dave 

I have to update a custom field of contact if the field status of campaignmember change.

How can I fire on campaignmember with a trigger?

I need a trigger like this:


trigger trigger1 on CampaignMember(after update) { join contact with campaignmember by id.... and then contact.custom_field__c = campaignmember.status }

 thanks

Is it possible to retrieve the url of a caller (a-la HTTP Referrer) on a visualforce page?

 

We need to be able to differentiate between posts from two different domains to a single visuaforce page.  For example calls from https://test.acme.com would trigger test processing while https://www.acme.com would trigger live processing.

 

Thanks,

I'm working on an Apex trigger and class that will geocode addresses on the contact object once a new contact record is created with an address (After Insert) and after a contact record's address has changed (After Update). I'm making and HTTP request to google to geocode the coordinates as in:

- send an address to Google

- if I get a response back from Google, check the status

- if successful, then parse through the response and extract the coordinates and write them to the contact record, so they can later be referenced by my Google Maps application.

 

Here's my problem: originally, I wrote the trigger and class so that it only sends one address per trigger execution. This code works as expected. Then I modified my code to send addresses in batches and now I'm getting the following error message:

 

System.AsyncException: Future method cannot be called from a future method: my method name goes here()

 

 

Here's what my code does:

Trigger

- when a new contact record with an address or when a existing contact record's address is updated, then add its id to an array

- call the apex class to geocode by passing this mentioned array of contact ids

 

Class

- for each contact that was passed by the trigger, query the address and pass it to Google for geocoding

- read the response back from Google and if it was successful, then parse through the response, extract the coordinates and write to the contact record (update call)

 

Why would I get the following error message? Are bulk triggers not allow when using the @future annotation or is there something wrong with my logic?

 

Thanks in advance.

 

 

I am getting this error when I go to save my trigger "Compile Error: expecting a left angle bracket, found 'ProductName' at line 2 column 10"

 

 

trigger RenewalItemUpdate on SFDC_520_QuoteLine__c (before insert, before update) {
    List ProductName = new List();
        for (Integer i = 0; i < Trigger.new.size(); i++)
        {
            ProductName.add(Trigger.new[i].Product2__c);
        }
    List RenewalList = new List([Select Id from Annual_Renewal_Pricebook_Item__c
     where GP_Item_Number__c in :ProductName]);
        for (Integer i = 0; i < Trigger.new.size(); i++)
        {
            if (Trigger.new[i].Product2__c != null)
            {
                Trigger.new[i].GP_Item_Number__c = RenewalList[i].Id;
            }
            else
            {
            Trigger.new[i].GP_Item_Number__c = null;
            }
        }
}

 

Can anyone look at this and see why I am getting this error?  I just need a fresh set of eyes.

Thanks!

Is there anything at a higher level than StreamReader to parse XML in Apex? I might be able to get the current issue resolved but it would be great to have anything else also.

As an aside, would someone know when Spring '09  is being released (I will have no need for workarounds once the promised feature set is available).

Hello,

I'm migrating a database for a Canadian group and they have a handy trigger (Access/VBA DLookup) in their Access database that finds a contact's province after insert, based on that person postal code. Postal codes in Canada are alphanumeric and the DLookup function enables a lookup within a range of alphanumeric values. For example, the postal code 'V3H 3A6' falls within the range 'V3H 2B7' and 'V3H 5S6', which represents all of the postal codes in a particular province. I have a table of values that defines the range but not each available postal code.

Is there any way to parse these alphanumeric ranges with Apex? In other words, can I find out if an alphanumeric string falls within a range of two alphanumeric strings. Can I use this existing table that defines only the ranges or do I need to build out my own new table? Or, is there a way to build in this logic into Apex to find an alphanumeric value in a range of two alphanumeric values?
Hi

I have a custom field in a custom object I need to update to a same value. The issue is that there are 100,000 records in this custom object and of course I will hit the governor limit to 10,000 records. I just want to create a button which will call an Apex Class for these 100,000 updates!

Has anyone had this problem and found a solution for it?

any ideas?

Thanks for your help