• 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));

}

}

}

 

 

 

  • August 26, 2009
  • Like
  • 0

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

Hello,

 

I'm experiencing a strange unmanaged package install failure today:

 

Your requested install failed. Please try this again.

None of the data or setup information in your salesforce.com organization should have been affected by this error.

If this error persists, contact salesforce.com Support through your normal channels and reference number: 149955118-1304 (-1360487324)

 

An older version of the same package installs just fine, but I uploaded a new version today, with some updated apex code but the schema remains the same.  This package is kicking the cryptic error message.  Any help would be appreciated. Thanks in advance.

I'm considering writing a batch cloning operation for opportunities.  I'm concerned that I'm going to bump up against governor limits, here's why:

 

I have quite a few triggers that fire on the creation of new opps.  They're all bulkified but I still run into heap size limits and occasionally SOQL rows when inserting (or updating) batches of opportunities greater than 40-50 through the API (DataLoader, DemandTools, etc.). 

 

As I understand it, batch apex won't let me work with batches smaller than 200, so my question is, will I run into the same heap size limits or SOQL rows in batch apex? When my DML is executed for my batch(es), and in turn fires triggers, are those triggers operating with trigger governor limits for this transaction, or within the higher batch apex governor limits?

Message Edited by DManelski on 08-26-2009 11:20 AM

I was under the impression that a describe call should access all fields on an object, regardless of whether or not they are hidden by FLS, am I wrong here?  A dynamic SOQL statement that I have is not returning hidden fields:

 

Code snippet:

 

//describe call to get lead fields for dynamic SOQL Map<String, Schema.SObjectField> leadFieldMap = Schema.SObjectType.Lead.fields.getMap(); //variable to hold dynamic SOQL of lead fields string querySOQL; // get all open leads public integer loadAllLeads() { system.debug ('lead schema map: ' + leadFieldMap); querySOQL = 'SELECT '; querySOQL += '(select campaignid from campaignmembers order by createddate desc),'; for (string fieldname : leadFieldMap.keyset()) { querySOQL += fieldname + ', '; } querySOQL = querySOQL.substring(0,querySOQL.length()-2); //lop off trailing comma querySOQL += ' FROM lead WHERE isConverted = false'; querySOQL += ' ORDER BY createddate limit :queryLimit'; system.debug ('query string: ' + querySOQL); leads = Database.Query(querySOQL); if (leads.isEmpty()) { return 0; } else { matchLeads(); return leads.size(); } }

 

 

 

I have a workflow rule that fires a time-based action (an email alert and field update) and this rule has been working fine, firing as expected thousands of times over the past couple of months since I created it.  This morning however, the workflow rule was due to fire on 4 records and bombed out (did not fire) on each of them.  I received four similarly worded email messages:

 

Subject: Salesforce workflow could not perform a pending action

Details:
Object Type: Drip Event

Record: DripEvent-014794
https://na2.salesforce.com/a0E40000001KG3S

Workflow Rules attempted: Healthy Kids Campaign Email Series 2
https://na2.salesforce.com/01Q40000000FMKj

Workflow Actions attempted: Healthy Kids Campaign Email Series 2
https://na2.salesforce.com/01W40000000D09T
Mark Send Completed
https://na2.salesforce.com/04Y400000000CgI

 

 

I experienced issues with time-based workflow when daylight savings time hit this past fall and the guidance from Salesforce  was to completely rebuild all of my workflow rules (which didn't correct the problem by the way, my workflow rules were still trying to send at 11:00pm the night before they were supposed to, and failing to fire).  My question -- is there a known issue with time-based workflow rules following the Spring '09 release?  I've looked over my workflow rule a dozen times today and nothing at all has changed in our Salesforce instance relating to this rule.

 

Thanks much!

Dave

Oakland based Green for All is hiring a Salesforce.com Administrator.

 

Green For All is a national organization dedicated to building an inclusive green economy strong enough to lift people out of poverty. By advocating for local, state and federal commitment to job creation, job training, and entrepreneurial opportunities in the emerging green economy – especially for people from disadvantaged communities – Green For All fights both poverty and pollution at the same time.

 

The Salesforce.com Administrator is responsible for leading the scoping, development, implementation, and ongoing administration of applications in Green For All's database of record, implemented on the Salesforce.com platform.  The database is currently used by Green For All's team to track our donors and prospects, campaigns, projects, volunteers, partners, and contacts.  The Salesforce database is integrated with Green For All's website as part of a comprehensive, data-centric approach to our work. There is also potential to expand the the database to other business functions moving forward.

 

Read more about the job and apply at:

http://www.greenforall.org/about-us/jobs/Salesforce-Administrator

Message Edited by DManelski on 02-10-2009 01:43 PM

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 

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?
Background:
I'm using a custom lead converter - VF Page, controller class, and separate LeadConversion class (for the heavy lifting). This lead converter overwrites a handful of fields, adds a new opportunity (there are a handful of opp fields on the lead object), and attaches that person to the opportunity by adding a contact role, among other features. On the VF page, the user has the option to choose a record type for a given lead with opportunity data. In lieu of hard-coding actual opportunity record type values into a custom field on the lead, I'd like to dynamically generate these values using a describe method to populate a selectList. Sounds easy enough, no problems right.

Problem:

The controller for the lead converter (which has a constructor) displays a list of leads to create, defined in the class leadResult, which in turn has its own constructor -- child class with a child class constructor. Currently, the describe method used to fetch the opportunity record types from the opportunity object is called for each lead in the leadResult class. For 20 leads on a page, 20 describe methods. The limit for describe calls in one transaction appears to be 10, which crashes my lead converter for anything over 10 lead records, causes tests to fail, etc.

Solution, and more problems:
The solution is to move my describe method outside of the leadResult class, so it isn't called for each lead on the page. However, I can't seem to move the describe to the top of the class and still access the variable holding the list of opportunity record types. I get the error that the variable does not exist. I've tried placing the describe call at the top of the class and in the controller constructor, both to no avail. I've also tried making the List variable public without success. I've even tried moving the describe method to a separate class, but since I'm referencing it from the leadResult still, it's calling a describe method each time. I don't quite understand why I can't see/use my variable from the top of my class, or when it's placed in the constructor, any ideas?

Here's my significantly truncated code:



Code:
public class ONEN_CTRL_LeadConverter {

   //constructor
 public ONEN_CTRL_LeadConverter() {
  //individual account id
  IndividualAccountId = ONEN_DefaultAccount.getIndividualAccountId();
  //individual account name
  IndividualAccountName = ONEN_Constants.INDIVIDUAL_ACCOUNT_NAME;
  //set the org name not provided default label
  NotProvidedLabel = ONEN_Constants.NOT_PROVIDED_LABEL;
 }
  
   
 
    // this class represents one row in the leads list
    public class leadResult {
  
  // constructor
     public leadResult(ONEN_LeadConversion.LeadMatchup matchup) { 
      
      
      //grab the Opp RecordTypes and throw them into a SelectOptions list
   Schema.DescribeSObjectResult OppRT = Opportunity.sObjectType.getDescribe();
   List<Schema.RecordTypeInfo> RT = OppRT.getRecordTypeInfos();
      
      RToptions.add(new SelectOption('','--Select Record Type--'));
         for ( Schema.RecordTypeInfo thisRT : RT ) {
          RToptions.add(new SelectOption(thisRT.getName(),thisRT.getName()));
         }
             }
     }
}

Seems to me like the child class constructor is being called before the controller constructor and therefore can't access any variables set there (or anywhere else in the class for that matter).  Any ideas?

Thanks in advance.
Hello,

We're trying to get all of our code up to API version 14.0 but I'm running into a problem with one of our triggers. 

It was originally created in API version 10.0.  The after update trigger grabs a trigger set via trigger.new, makes changes or deletes the records according to some basic logic.  This worked fine in API version 10.0 but under version 14.0, tests are now failing and I'm receiving this error:

"System.SObjectException: DML statment cannot operate on trigger.new or trigger.old"

This particular error is being thrown on a delete DML in the trigger. Any ideas?

Hello,

I'm trying to write a very simple list button to update Opportunities from the Opportunity related lists on contact and account.  I'd like to be able to check off a few opportunity records and then click a button to change them as Closed Won or Closed Lost.  Ideally, I'd like the extension to just perform the action without having to confirm/save the records on a separate VF page.  In other words, all I need a VF page to do is execute the action and return the user to the contact or account record from which he/she started.  Here's what I've got so far:

Visualforce page:

Code:
<apex:page standardController="Opportunity" recordSetVar="opportunities" extensions="ONEN_EXT_UpdateOpportunities" action="{!MarkAsWon}">
</apex:page>

And the extension:
Code:
public class ONEN_EXT_UpdateOpportunities {

 public List<Opportunity> selectedOpps = new List<Opportunity>();

 public ONEN_EXT_UpdateOpportunities(ApexPages.StandardSetController controller) {
             this.selectedOpps = (list<Opportunity>)controller.getRecords();
        }
 
 public pageReference MarkAsWon() {
  
  List<Opportunity> OppsToUpdate = new List<Opportunity>();
  for (Opportunity newOpp : selectedOpps) {
   newOpp = new Opportunity (
    id = newOpp.id,
    StageName = 'Won Not Thanked'
   );
   OppsToUpdate.add(newOpp);
  }
  
  if (OppsToUpdate.size() > 0) {
   update OppsToUpdate;
  }
  
  PageReference p = new PageReference('/' + ApexPages.currentPage().getParameters().get('id'));
p.setRedirect(true);
return p; } }

I just don't know how to retrieve/set/manipulate the selected records in my extension. Any guidance would be greatly appreciated.

Dave



Message Edited by DManelski on 12-19-2008 08:32 AM
I know how to perform this function using a formula in a workflow rule:

Code:
CASE( MOD(  TODAY()  - DATE(1900, 1, 7), 7),

2, TODAY(),

3, TODAY()+6,

4, TODAY()+5,

5, TODAY()+4,

6, TODAY()+3,

0, TODAY()+2,

1, TODAY()+1,

TODAY() )


How do I do this very same thing in an Apex trigger?

I tried this, and it set the date to Tuesday of this week:
Code:
Email_Series_Start_Date__c = System.today().toStartOfWeek()+2;    

However, I'd really like to set it to the next Tuesday if Tuesday has already passed this week. As an aside, this date field is driving the start date for an email drip campaign which should send on Tuesdays.
 
Thanks in advance.

Dave M.


Message Edited by DManelski on 10-22-2008 03:54 PM
Hello,

I'm trying to create a test for my controller extension (standard controller is Contact).  To summarize what the extension does, upon save of a VF page, one contact field is saved/updated and then the extension takes over and a new child record (to contact) is created.

The extension works great, as intended, but I'm having trouble calling the Save method from my test class.  In standard apex tests, you call a DML action like update, insert, etc. but when testing an extension, you're testing the method in the extension itself.  It follows that you need to call that method in the the test and I can't seem to figure out how.  Any help would be greatly appreciated.  Here's my code:

Controller Extension:
Code:
public class ONEN_Job_Change{
   
id ContactId;
id OldAccountId;
Contact contact = new Contact();
ONEN_Organization_2_Contact_Relationship__c relationship = new ONEN_Organization_2_Contact_Relationship__c();

    public ONEN_Job_Change(ApexPages.StandardController controller) {
        this.contact = (Contact)controller.getRecord();
        OldAccountId = contact.AccountId;
    }


    public ONEN_Organization_2_Contact_Relationship__c getRelationship() {
        
        if(relationship == null) relationship = new ONEN_Organization_2_Contact_Relationship__c();
        return relationship;
    }
    
    
    
    public PageReference save() {
        
        update contact;
        
        relationship.Organization__c = OldAccountId;
        relationship.Contact__c = contact.id;
        relationship.Type__c = 'Employee';
        
        insert relationship;
        
                
        PageReference p = new PageReference('/' + System.currentPageReference().getParameters().get('id'));
        p.setRedirect(true);
        return p;
    }

}

 And the test...

Code:
// Written by Dave Manelski, copyright (c) 2008 ONE/Northwest
// This program is released under the GNU General Public License. http://www.gnu.org/licenses/
public class ONEN_Test_Job_Change {

static testMethod void ONEN_Test_Changing_The_Job() {
Test.setCurrentPageReference(new PageReference('Page.Job_Change'));
ONEN_Organization_2_Contact_Relationship__c relationship = new ONEN_Organization_2_Contact_Relationship__c();
Id FirstContactId;
Id AccountId1;
Id AccountId2;

Account newAccount1 = new Account (
name='XYZ Organization'
);
insert newAccount1;
AccountId1 = newAccount1.id;

//create first contact
Contact firstContact = new Contact (
FirstName='Joe',
LastName='Schmoe',
AccountId=AccountId1
);
insert firstContact;

ApexPages.StandardController sc = new ApexPages.standardController(firstContact);
ONEN_Job_Change ext = new ONEN_Job_Change(sc);
String savePage = ext.save().getUrl();




Contact createdContact = [select Account.Name from Contact where Id =:firstContact.id];

System.assertEquals('XYZ Organization',createdContact.Account.Name);


//create second account
Account newAccount2 = new Account (
name='ABC Organization'
);
insert newAccount2;

AccountId2 = newAccount2.id;

//ext = new ONEN_Job_Change(sc);
ext.firstContact.AccountId = AccountId2;
savePage = ext.save().getUrl();



System.assertEquals('ABC Organization',createdContact.Account.Name);

relationship = [select id, Contact__c, Organization__c, Type__c, End_Date__c from ONEN_Organization_2_Contact_Relationship__c where Contact__c = :FirstContactId];

System.assertEquals('XYZ Organization',relationship.Organization__c);
System.assertEquals('Employee',relationship.Type__c);


}
}

FYI, this test does not compile, I'm getting a save error that the Variable Does not Exist: firstContact on the line in bold above.

Lastly, here's my VF page for reference:
Code:
<apex:page standardController="Contact" extensions="ONEN_Job_Change">   
    <apex:sectionHeader title="Terminate Employee Relationship"/>
    <apex:form >
    <apex:pageBlock title="Choose New Organization and Previous Employment End Date">
        <apex:pageBlockSection columns="1"> 
            <apex:inputField value="{!contact.AccountId}" />
            <apex:inputField value="{!relationship.End_Date__c}"/>        
        </apex:pageBlockSection>  
            <apex:pageBlockButtons >
                    <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
        
    </apex:pageBlock>
    </apex:form>
</apex:page>


Message Edited by DManelski on 07-10-2008 05:54 PM

Message Edited by DManelski on 07-10-2008 05:54 PM
I've created a simple extension to disassociate a Contact from an Account, fired from a Detail Page Button.  The controller is a standard contact controller with an extension to add a related record to a Contact to Org. junction object, which creates a former employment record.  The button brings up a VF page that asks for a new Account and employment end date.  Upon clicking save, the contact is associated with the new account using the standard controller and the extension takes care of creating the new contact to org. former employment record. 

The extension and VF page works great, no problems, but I'm having trouble determining the syntax for the test.  Any help would be greatly appreciated. The error I'm receiving: Save error: Constructor not defined: [ONEN_Job_Change].<Constructor>()  

Here's my code:

Code:
public class ONEN_Job_Change{
   
id ContactId;
id OldAccountId;
Contact contact = new Contact();
ONEN_Organization_2_Contact_Relationship__c relationship = new ONEN_Organization_2_Contact_Relationship__c();

    public ONEN_Job_Change(ApexPages.StandardController controller) {
        this.contact = (Contact)controller.getRecord();
        OldAccountId = contact.AccountId;
    }


    public ONEN_Organization_2_Contact_Relationship__c getRelationship() {
        
        if(relationship == null) relationship = new ONEN_Organization_2_Contact_Relationship__c();
        return relationship;
    }
    
    
    
    public PageReference save() {
        
        update contact;
        
        relationship.Organization__c = OldAccountId;
        relationship.Contact__c = contact.id;
        relationship.Type__c = 'Employee';
        
        insert relationship;
        
                
        PageReference p = new PageReference('/' + System.currentPageReference().getParameters().get('id'));
        p.setRedirect(true);
        return p;
    }

}


public class ONEN_Test_Job_Change {
 
 static testMethod void ONEN_Test_Changing_The_Job() {  
  
  Test.setCurrentPageReference(Page.Job_Change);
  
  ONEN_Job_Change ext = new ONEN_Job_Change();
  
  Id FirstContactId;
  Id AccountId1;
  Id AccountId2;   
  
  //create first account
  Account newAccount1 = new Account (
   name='XYZ Organization'
  );
  insert newAccount1;
  
  AccountId1 = newAccount1.id;
  
  //create first contact
  Contact firstContact = new Contact (
  FirstName='Joe',
  LastName='Schmoe',
  AccountId=AccountId1   
  );
  insert firstContact;
  
  Contact createdFirstContact = [select Account.Name from Contact where Id =:firstContact.id];
  
  System.assertEquals('XYZ Organization',createdFirstContact.Account.Name);
  
  //create second account
  Account newAccount2 = new Account (
   name='ABC Organization'
  );
  insert newAccount2;
  
  AccountId2 = newAccount2.id; 
  
  
...more code here...  
 }
}

 



Message Edited by DManelski on 07-01-2008 03:55 PM
I've created a simple trigger that marks a checkbox (True) on a contact record, when a new child record is created that also has a specific checkbox checked.  The child records are created through an AppExchange packed App, in other words it's not possible to click a New button and create one of these child records through the UI.

My trigger worked just fine, compiled a-okay.

In creating a Test class however, I'm receiving the following error:

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ManagedPackageObject: Execution AfterInsert


I can't really test if my trigger works in a Sandbox given that it's a manage package that connects to and communicates with an external web app.  Any ideas for how I can get my test to insert the new record I need to get the test to run correctly?

Thanks in advance.

Dave

For reference:

Trigger:

Code:
trigger ONEN_Contact_MarkBadEmail on vr__VR_Email_History_Contact__c (after insert, after update) {

 // every time we a VR Email History is added to the contact record, or updated from Vertical Reponse
 // and the VR Email History Contact has a bounced checkbox marked as true, update the contact field
 // Bad Email Addresss to True.
 
 list<Id> ContactIdsToUpdate = new list<Id>();
 vr__VR_Email_History_Contact__c BouncedEmail = new vr__VR_Email_History_Contact__c();
 list<Contact> ContactsToUpdate = new list<Contact>();
 
 // create a list of Contact IDs that have VR Email History record with Bounced checked
 for (vr__VR_Email_History_Contact__c thisEmailRecord : trigger.new) {
 
  if ( thisEmailRecord.vr__Bounced__c = True ) {
   ContactIdsToUpdate.add (thisEmailRecord.vr__Contact__c);
  }
 }
 
 if ( ContactIdsToUpdate.size() > 0 ) {
  for (Id BouncedContacts : ContactIdsToUpdate) {
   Contact thisContact = new Contact (
   Id = BouncedContacts, 
   Bad_Email_Address__c = True
   );
   ContactsToUpdate.add (thisContact);
  
  }
  
  insert ContactsToUpdate;
 }
 
}

Test:
Code:
public class ONEN_Test_Contact_MarkBadEmail {

 static testMethod void Contact_MarkedAsBadEmail () {
  
  Contact testContact = new Contact (
   LastName = 'Schmoe',
   Bad_Email_Address__c = False
  );
  insert testContact;
  
  vr__VR_Email_History_Contact__c testEmailHistory = new vr__VR_Email_History_Contact__c (
   Name = 'Test Campaign Email',
   vr__Bounced__c = False,
   vr__Contact__c = testContact.Id
  );
  insert testEmailHistory;
  
  testContact = [select id, Bad_Email_Address__c from Contact where id=:testContact.Id];
  
  system.assertEquals(testContact.Bad_Email_Address__c, True);
 }


}

 



Message Edited by DManelski on 06-20-2008 12:36 PM

Message Edited by DManelski on 06-20-2008 12:40 PM

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

}

}

}

 

 

 

  • August 26, 2009
  • Like
  • 0

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.

 

 

  • January 23, 2009
  • Like
  • 0

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