• dbruns
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 7
    Replies

I have been following the PKB setup guide to the letter and have verified that my Category Group unique name and Category Root unique name are correct and active. Yet, I am still getting the following error when going to the PKB site. Does anyone have a solution to this issue?

 

https://sites.secure.force.com/appexchange/listingDetail?listingId=a0N30000001gFH9EAM

 

Error: The PKB Site Setup is not configured correctly. Please verify that the category group name is correct and that the group is active.

  • August 03, 2011
  • Like
  • 0

Newbie developer here. I am having a problem trying to solve an issue with too many queries using scheduled APEX. We have the following Account trigger that fires before update:

 

 

 

I am trying to update all Accounts en masse on the 1st of every month using Scheduled APEX, however, my Class will only work for a limited # of Accounts:

Works when I pass one record:

global class RunPartnerPerformance
{
    Set<Account> accs = new Set<Account>([select ID from Account where RecordTypeID = '012400000009Xes']);
    // Gets a unique list of Account ids
    {
    for ( Account account : accs ) 
          {if (account.ID == '0014000000L1CQQ')
            {
            update account;
            }
         }

    }
}

 

global class RunPartnerPerformance
{
    Set<Account> accs = new Set<Account>([select ID from Account where RecordTypeID = '012400000009Xes'] limit 1);
    // Gets a unique list of Account ids
    {
    for ( Account account : accs ) 
            {
            update account;      
            }

    }
}


Does not work in bulk:

global class RunPartnerPerformance
{
    Set<Account> accs = new Set<Account>([select ID from Account where RecordTypeID = '012400000009Xes']);
    // Gets a unique list of Account ids
    {
    for ( Account account : accs ) 
            {
            update account;      
            }

    }
}

 

Any suggestions are greatly appreciated!

  • April 16, 2010
  • Like
  • 0

Hello everyone,

 

 

I am very green to writing APEX and am hoping that someone might be willing to lend some advice. I have created a trigger that updates a Contact with queried information from Leads and Opportunities:

 

trigger PartnerPerformance on Contact bulk(before insert, before update){ Contact myContact = trigger.new[0]; public String getL() { if (l == null) l = 0; return '' + l; } integer l = [SELECT count() FROM Lead WHERE (lead.createddate = LAST_N_DAYS:180) AND (lead.Referring_Contact__c = :myContact.Id) LIMIT 100]; public String getQ() { if (q == null) q = 0; return '' + q; } integer q = [SELECT count() FROM Opportunity WHERE (opportunity.createddate = LAST_N_DAYS:180) AND (opportunity.Referring_Contact__c = :myContact.Id) LIMIT 1]; public String getC() { if (c == null) c = 0; return '' + c; } integer c = [SELECT count() FROM Opportunity WHERE (opportunity.closedate = LAST_N_DAYS:180) AND (opportunity.stagename = 'Closed Won') AND (opportunity.Referring_Contact__c = :myContact.Id) LIMIT 100]; if (myContact.Id != null) { myContact.Referred_Leads__c = l; myContact.Qualified_Leads__c = q; myContact.Closed_Won_Opps__c = c; } }

 

The challenge is that my Test Code only covers 40% and disregards all of my Public Strings. Can anyone provide an example of how to test the Public String established in the trigger? Thank you!

 

@istest private class PastPerformanceTriggerTest { static testMethod void canInsertPerformance(){ Account account = TestUtilities.setupAccountTestData(); Account partneraccount= new Account(Name = 'TestPartnerAccount', Phone = '(000) 000-0000'); insert partneraccount; Contact contact = TestUtilities.setupContactTestData(); Contact partner = new Contact(FirstName = 'Test', LastName = 'Partner', Partner_Tier__c= 'Standard', Phone = '(000) 000-0000', Email = 'unk@guidantfinancial.com', AccountID = partneraccount.ID); test.startTest(); insert partner; if(partner.Referred_Leads__c == 0){ System.Assert(false); } else{ System.Assert(true); } if(partner.Qualified_Leads__c == 0){ System.Assert(false); } else{ System.Assert(true); } if(partner.Closed_Won_Opps__c == 0){ System.Assert(false); } else{ System.Assert(true); } test.stopTest(); } static testMethod void canUpdatePerformance(){ Account account = TestUtilities.setupAccountTestData(); Account partneraccount= new Account(Name = 'TestPartnerAccount', Phone = '(000) 000-0000'); insert partneraccount; Contact contact = TestUtilities.setupContactTestData(); Contact partner = new Contact(FirstName = 'Test', LastName = 'Partner', Partner_Tier__c= 'Standard', Phone = '(000) 000-0000', Email = 'unk@guidantfinancial.com', AccountID = partneraccount.ID); insert partner; Lead lead = TestUtilities.setupLeadTestData(); Lead partnerlead= new Lead(FirstName = 'Test', LastName = 'One', Company = 'Test Company', Status = 'Outreach', Phone = '(000) 000-0000', Email = 'unk@guidantfinancial.com', ProductInterest__c = '401k Small Business Financing', Referring_Contact__c = partner.Id); Lead nonpartnerlead= new Lead(FirstName = 'Test', LastName = 'Two', Company = 'Test Company', Status = 'Outreach', Phone = '(000) 000-0000', Email = 'unk@guidantfinancial.com', ProductInterest__c = '401k Small Business Financing'); insert partnerlead; insert nonpartnerlead; Opportunity opportunity = TestUtilities.setupOpportunityTestData(); Opportunity opportunity1 = new Opportunity(Name = 'Test Partner Opportunity', AccountID = partneraccount.Id, CloseDate = date.today(), StageName = 'Closed Won', Areas_of_Interest__c = 'Business: Existing', Product_Interest__c = '401k Small Business Financing'); insert opportunity1; test.startTest(); update partner; if(partner.Referred_Leads__c == 1){ System.Assert(false); } else{ System.Assert(true); } if(partner.Qualified_Leads__c == 1){ System.Assert(false); } else{ System.Assert(true); } if(partner.Closed_Won_Opps__c == 1){ System.Assert(false); } else{ System.Assert(true); } test.stopTest(); } }

 

Message Edited by dbruns on 12-21-2009 11:43 PM
  • December 22, 2009
  • Like
  • 0

Hello,

 

I wrote the following trigger to prevent deletion of a Closed Won Opportunity:

 

 


trigger CannotDeleteClosedWon on Opportunity (before delete) 

{

    if(system.Trigger.isDelete)

    {

    for (Opportunity Opps : trigger.new)

         if (Opps.StageName == 'Closed Won')

            {

            Opps.addError('Cannot delete a Closed Won Opportunity');

            }

    }




}

 

The problem, I keep getting sent to a page with the following message:

 

CannotDeleteClosedWon: execution of BeforeDelete

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.CannotDeleteClosedWon: line 5, column 29

 

Any suggestions?

  • November 20, 2009
  • Like
  • 0

I have been following the PKB setup guide to the letter and have verified that my Category Group unique name and Category Root unique name are correct and active. Yet, I am still getting the following error when going to the PKB site. Does anyone have a solution to this issue?

 

https://sites.secure.force.com/appexchange/listingDetail?listingId=a0N30000001gFH9EAM

 

Error: The PKB Site Setup is not configured correctly. Please verify that the category group name is correct and that the group is active.

  • August 03, 2011
  • Like
  • 0

Newbie developer here. I am having a problem trying to solve an issue with too many queries using scheduled APEX. We have the following Account trigger that fires before update:

 

 

 

I am trying to update all Accounts en masse on the 1st of every month using Scheduled APEX, however, my Class will only work for a limited # of Accounts:

Works when I pass one record:

global class RunPartnerPerformance
{
    Set<Account> accs = new Set<Account>([select ID from Account where RecordTypeID = '012400000009Xes']);
    // Gets a unique list of Account ids
    {
    for ( Account account : accs ) 
          {if (account.ID == '0014000000L1CQQ')
            {
            update account;
            }
         }

    }
}

 

global class RunPartnerPerformance
{
    Set<Account> accs = new Set<Account>([select ID from Account where RecordTypeID = '012400000009Xes'] limit 1);
    // Gets a unique list of Account ids
    {
    for ( Account account : accs ) 
            {
            update account;      
            }

    }
}


Does not work in bulk:

global class RunPartnerPerformance
{
    Set<Account> accs = new Set<Account>([select ID from Account where RecordTypeID = '012400000009Xes']);
    // Gets a unique list of Account ids
    {
    for ( Account account : accs ) 
            {
            update account;      
            }

    }
}

 

Any suggestions are greatly appreciated!

  • April 16, 2010
  • Like
  • 0

Hello everyone,

 

 

I am very green to writing APEX and am hoping that someone might be willing to lend some advice. I have created a trigger that updates a Contact with queried information from Leads and Opportunities:

 

trigger PartnerPerformance on Contact bulk(before insert, before update){ Contact myContact = trigger.new[0]; public String getL() { if (l == null) l = 0; return '' + l; } integer l = [SELECT count() FROM Lead WHERE (lead.createddate = LAST_N_DAYS:180) AND (lead.Referring_Contact__c = :myContact.Id) LIMIT 100]; public String getQ() { if (q == null) q = 0; return '' + q; } integer q = [SELECT count() FROM Opportunity WHERE (opportunity.createddate = LAST_N_DAYS:180) AND (opportunity.Referring_Contact__c = :myContact.Id) LIMIT 1]; public String getC() { if (c == null) c = 0; return '' + c; } integer c = [SELECT count() FROM Opportunity WHERE (opportunity.closedate = LAST_N_DAYS:180) AND (opportunity.stagename = 'Closed Won') AND (opportunity.Referring_Contact__c = :myContact.Id) LIMIT 100]; if (myContact.Id != null) { myContact.Referred_Leads__c = l; myContact.Qualified_Leads__c = q; myContact.Closed_Won_Opps__c = c; } }

 

The challenge is that my Test Code only covers 40% and disregards all of my Public Strings. Can anyone provide an example of how to test the Public String established in the trigger? Thank you!

 

@istest private class PastPerformanceTriggerTest { static testMethod void canInsertPerformance(){ Account account = TestUtilities.setupAccountTestData(); Account partneraccount= new Account(Name = 'TestPartnerAccount', Phone = '(000) 000-0000'); insert partneraccount; Contact contact = TestUtilities.setupContactTestData(); Contact partner = new Contact(FirstName = 'Test', LastName = 'Partner', Partner_Tier__c= 'Standard', Phone = '(000) 000-0000', Email = 'unk@guidantfinancial.com', AccountID = partneraccount.ID); test.startTest(); insert partner; if(partner.Referred_Leads__c == 0){ System.Assert(false); } else{ System.Assert(true); } if(partner.Qualified_Leads__c == 0){ System.Assert(false); } else{ System.Assert(true); } if(partner.Closed_Won_Opps__c == 0){ System.Assert(false); } else{ System.Assert(true); } test.stopTest(); } static testMethod void canUpdatePerformance(){ Account account = TestUtilities.setupAccountTestData(); Account partneraccount= new Account(Name = 'TestPartnerAccount', Phone = '(000) 000-0000'); insert partneraccount; Contact contact = TestUtilities.setupContactTestData(); Contact partner = new Contact(FirstName = 'Test', LastName = 'Partner', Partner_Tier__c= 'Standard', Phone = '(000) 000-0000', Email = 'unk@guidantfinancial.com', AccountID = partneraccount.ID); insert partner; Lead lead = TestUtilities.setupLeadTestData(); Lead partnerlead= new Lead(FirstName = 'Test', LastName = 'One', Company = 'Test Company', Status = 'Outreach', Phone = '(000) 000-0000', Email = 'unk@guidantfinancial.com', ProductInterest__c = '401k Small Business Financing', Referring_Contact__c = partner.Id); Lead nonpartnerlead= new Lead(FirstName = 'Test', LastName = 'Two', Company = 'Test Company', Status = 'Outreach', Phone = '(000) 000-0000', Email = 'unk@guidantfinancial.com', ProductInterest__c = '401k Small Business Financing'); insert partnerlead; insert nonpartnerlead; Opportunity opportunity = TestUtilities.setupOpportunityTestData(); Opportunity opportunity1 = new Opportunity(Name = 'Test Partner Opportunity', AccountID = partneraccount.Id, CloseDate = date.today(), StageName = 'Closed Won', Areas_of_Interest__c = 'Business: Existing', Product_Interest__c = '401k Small Business Financing'); insert opportunity1; test.startTest(); update partner; if(partner.Referred_Leads__c == 1){ System.Assert(false); } else{ System.Assert(true); } if(partner.Qualified_Leads__c == 1){ System.Assert(false); } else{ System.Assert(true); } if(partner.Closed_Won_Opps__c == 1){ System.Assert(false); } else{ System.Assert(true); } test.stopTest(); } }

 

Message Edited by dbruns on 12-21-2009 11:43 PM
  • December 22, 2009
  • Like
  • 0

Hello,

 

I wrote the following trigger to prevent deletion of a Closed Won Opportunity:

 

 


trigger CannotDeleteClosedWon on Opportunity (before delete) 

{

    if(system.Trigger.isDelete)

    {

    for (Opportunity Opps : trigger.new)

         if (Opps.StageName == 'Closed Won')

            {

            Opps.addError('Cannot delete a Closed Won Opportunity');

            }

    }




}

 

The problem, I keep getting sent to a page with the following message:

 

CannotDeleteClosedWon: execution of BeforeDelete

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.CannotDeleteClosedWon: line 5, column 29

 

Any suggestions?

  • November 20, 2009
  • Like
  • 0
I have an issue with the Excel Connector.  I am trying to import some new leads in to Salesforce and it is failing with the above mentioned error on the Owner ID field.  I am putting the full username into the field.  ie. Alain Obrien in this example.  This is the same format I used when importing contacts and accounts etc and I had no issues.
 
The bizaar bit is if I use the wizard to extract leads into Excel, it shows the owner ID as I have described above.  If I change nothing, and try and use the update option, it fails with the same error.  So its failing to update with the data it has just extracted.
 
Any assistance would be most appreciated.
 
Thanks
 
 
Chris
  • September 10, 2008
  • Like
  • 0
I have two fields - one in a standard object and one in a custom object.

When the value for the field in the standard object is populated I would like the corresponding field in the custom object to be updated with the same value.  Is there a way to do this?