• IC-Tanner
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 20
    Replies

Via our managed package, users are getting a “Attempt to re-reference null object” error when access a VF page. The error references the following system method: sobjType.getDescribe(). Here is the full code:

 Schema.SObjectType sobjType = gd.get('npe01__OppPayment__c');  
 Schema.DescribeSObjectResult r = sobjType.getDescribe();

I assumed this was due to a a lack of read access on the 'npe01__OppPayment__c' object but the error still occurs after access is provided ( as well as with full CRUD access). The error only goes away when the "Customize Application"  permission is provided on the profile. Any insight if there is another permission that is appliable or why else this is occuring? We cannot provide the "Customize Application" permission.

Thanks!

A VF page has a command button that adds a new object record to a list and then re-renders the VF page which displays the list via an <apex;repeat> component. Everything works as expected though randomly the page re-render (button submission) fails and the 'Generic Error Page' page is displayed. The debug log doesn't show any errors. The only thing I can think of is possible the setter methods are randomly not running correctly before the page re-renders. Possibly due to javascript onComplete?

Button:

<apex:commandButton styleClass="btn" action="{!addDisbursmentEntry}" value="Add another student" reRender="frm" onComplete="toBottom()" disabled = "{!numberOfDisbursments > 9 || YearEndReportSubmitted || readOnlyUser}" />

Related Method:
public void addDisbursmentEntry()
{
                    Transactions__c transHolder = new Transactions__c(
                    School__c = accountHolder.id,
                    Year_End_Report__c = yearEndReport.id,
                    Transaction_Type__c = 'Disbursement'       
                    );        
                    disbursmentList.add(transHolder);
}

The page re-render is for the the '<apex:form> component which contains the repeat component:
<apex:repeat value="{!disbursmentList}" var="disbursment">

Javascript called:
<script>
function toBottom()
{
window.scrollTo(0, document.body.scrollHeight);
}
</script>

Thanks!!

Has anyone seen a 'new component' issue before for a 'summary layout' component (for a patch version)?  I'm assuming it was something added in Summer '12 as I haven't been able to determine what a 'summary layout' component is. It seems that something was added in Summer '12 that is going to force me to do a major release instead of being able to release a patch version. When I click on the links to the components, I just receive an 'Insufficient Privileges' message. My thought is that is related to the 'Highlights Panel' of Page Layouts though I thought this was added in Summer '11. 

 

Thanks!

 



 

 

 I am trying to bulk a trigger but have run into issues with the normal set/map method and therefore cannot figure out how to bulk the trigger. 
Quick background:
-before 'lead' object insert, query 'AFS_Zip__c' object to determine what the 'area team' is for the lead based on the lead's postal code referenced against a postal code range on the 'AFS_Zip__c'' object. 
-Normally I would just add all the 'trigger.new' postal codes to a set, then run one SOQL query to obtain all the 'area team' field values from the 'AFS_Zip__c' object based on 'in' set.  Because the 'AFS_Zip__c'' object provides a range of postal codes per 'area team', 'in' doesn't work. I therefore tried to add all the 'AFS_Zip__c' object'object records to a map but ran into  the '1000 record limit on SOQL queries per trigger'. because the 'AFS_Zip__c' object contains 4000+ records. 
Working code but not bulkified:
trigger TrgIns_SetDefaultValues on Lead (before insert,before update) 
{
    integer IsATFound;
    
    IsAtFound = 0;  
    
    for(Lead lead : trigger.new)    
    {       
        for (AFS_Zip__c az : [Select Name from AFS_Zip__c az where az.FromZip__c <= :lead.PostalCode and 
             az.ZipTo__c >= :lead.PostalCode]) 
        { 
            lead.Area_Team__c = az.name; 
            IsATFound = 1;  
        }//close for AFS_zip 
          
        if (IsATFound == 0) 
        { 
            lead.Area_Team__c = 'Un-Repped'; 
        }            
    }    
}

updated code that is running into '1000 record limit on SOQL queries per trigger' limit:
trigger TrgIns_SetDefaultValues_beta on Lead (before insert,before update) 
{
    map<string, string> zipMap = new map<string,string>();
     
    //creates lists of 'AFS_Zip__c' records. Issue is that the total query records size returned is 4000+
    
    for(list<AFS_Zip__c> zipList : [select id, name, FromZip__c, ZipTo__c from AFS_Zip__c])
    {    
        //for each 'AFS_Zip__c' record, determine upper and lower postal code values and 
        //map each value in the range to the 'name' field
        for (AFS_Zip__c zip : zipList)
        {         
            for(integer zipValue = integer.valueOf(zip.FromZip__c); zipValue <= integer.valueOf(zip.ZipTo__c); zipValue++)
            {
                zipMap.put(string.valueOf(zipValue), zip.name);      
            }       
        }
    }      
    
    for(Lead lead : trigger.new)    
    { 
        //if lead zip code is found in the map (~'AFS_Zip__c' postal code range'), then update the lead 'Area_Team__c 
        //field. If not, update it as 'Un-Repped'
        if(zipMap.containsKey(lead.PostalCode))
        {
            lead.Area_Team__c = zipMap.get(lead.PostalCode);
        }
        else
        {
            lead.Area_Team__c = 'Un-Repped'; 
        }  
    }   
}
------------------------------------------
Logically, I need to determine a means of only querying/mapping for the 'postal code' values from the 'trigger.new' but can't determine a method to do this because of the range. I thought about using custom settings to get around the SOQL record limits but the range check doesn't seem possible via the custom settings methods (getAll(), etc.) without using SOQL. 
Any suggestions would be greatly appreciated. Thanks!!

 

 

I tried to deploy a non 'Chatter' related Apex class & trigger today and received the following error fired by a the test method of the chatterConnector Class. Because the Chatter APEX classes/triggers are not part of a managed package, the chatter test methods are firing for my unrelated code. Therefore I cannot deploy, update, or delete any APEX classes/triggers which is a major issue. Salesforce, can you please update this test method or allow unpackaged classes/triggers to be deployed without calling the Chatter test methods?

 

Feel free to contact me directly with any database instance specific questions.

 

Thank you!

 

Related info from Debug log:

 

17:45:6.650|EXECUTION_STARTED

17:45:6.650|CODE_UNIT_STARTED|[EXTERNAL]chatterConnector.main

17:45:6.653|METHOD_ENTRY|[15,50]|MAP:String,String.get(String)

17:45:6.653|METHOD_ENTRY|[15,34]|System.PageReference.getparameters()

17:45:6.653|METHOD_ENTRY|[15,10]|ApexPages.currentpage()

17:45:6.653|METHOD_EXIT|[15,10]|currentPage()

17:45:6.653|METHOD_EXIT|[15,34]|getParameters()

17:45:6.653|METHOD_EXIT|[15,50]|get(ANY)

17:45:6.653|METHOD_ENTRY|[26,9]|chatterConnector.buildUserList()

17:45:6.653|SOQL_EXECUTE_BEGIN|[77,19]|Aggregations:0|select id, name, userroleid, profileid, department, state, country,

            managerid, manager.name, manager.managerid, manager.manager.managerid, manager.manager.manager.managerid, manager.manager.manager.manager.managerid

            from User

            where id = :Userinfo.getUserId()

17:45:6.661|METHOD_ENTRY|[80,25]|Userinfo.getUserId()

17:45:6.661|METHOD_EXIT|[80,25]|getUserId()

17:45:6.671|SOQL_EXECUTE_END|[77,19]|Rows:1|Duration:18

17:45:6.672|METHOD_ENTRY|[84,23]|integer.valueof(String)

17:45:6.672|METHOD_EXIT|[84,23]|valueOf(String)

17:45:6.674|METHOD_ENTRY|[89,79]|UserInfo.getUserId()

17:45:6.674|METHOD_EXIT|[89,79]|getUserId()

17:45:6.678|METHOD_ENTRY|[137,24]|Database.query(String)

17:45:6.681|SOQL_EXECUTE_BEGIN|[137,24]|Aggregations:0|select id, name, managerid, title, city, state, department, createddate from User where isactive = true and usertype = 'Standard' and id <> '00550000000ymonAAA'  limit 1000

17:45:6.685|SOQL_EXECUTE_END|[137,24]|Rows:41|Duration:4

17:45:6.685|METHOD_EXIT|[137,24]|query(String)

17:45:6.685|SOQL_EXECUTE_BEGIN|[141,45]|Aggregations:0|select id, subscriberid

            from EntitySubscription

            where subscriberid IN :uList

            and parentid = :UserInfo.getUserId()

17:45:6.699|METHOD_ENTRY|[144,29]|UserInfo.getUserId()

17:45:6.699|METHOD_EXIT|[144,29]|getUserId()

17:45:6.710|SOQL_EXECUTE_END|[141,45]|Rows:0|Duration:25

17:45:6.711|SOQL_EXECUTE_BEGIN|[152,44]|Aggregations:0|select id, parentid

            from EntitySubscription

            where subscriberid = :UserInfo.getUserId()

            and parentid IN :uList

17:45:6.715|METHOD_ENTRY|[154,35]|UserInfo.getUserId()

17:45:6.715|METHOD_EXIT|[154,35]|getUserId()

17:45:6.725|SOQL_EXECUTE_END|[152,44]|Rows:1|Duration:14

17:45:6.725|METHOD_ENTRY|[160,13]|SET:Id.add(Id)

17:45:6.727|METHOD_EXIT|[160,13]|add(ANY)

17:45:6.727|SOQL_EXECUTE_BEGIN|[163,45]|Aggregations:0|select subscriberid, count(id)

            from EntitySubscription

            where subscriberid IN :uList

            group by subscriberid

            order by count(id) desc

            limit 200

17:45:6.733|SOQL_EXECUTE_END|[163,45]|Rows:21|Duration:6

17:45:6.733|EXCEPTION_THROWN|[163,45]|System.Exception: Too many query rows: 1090

17:45:6.733|METHOD_EXIT|[26,9]|buildUserList()

17:45:6.733|FATAL_ERROR|System.Exception: Too many query rows: 1090

 

Hi, I would like to create an <apex:dataTable> based on the logic of the 'sort="popular"' attribute of the 'ideas:listOutputLink' component. Because the code behind this component is not exposed, I'm unable to determine the query logic utilized for this attribute. I also have been able to determine the logic from reviewing the 'ideas' listed for the ''sort="popular"' attribute via testing. Does anyone know the query logic utilized for the 'sort' attibute and corresponding 'popular' value so that I can replicate it?

 

Thanks!

Hi, I have an APEX trigger that creates a new account record and then updates the contact record associating the contact to the new account via the 'account' lookup field (parent/child). Everything works correctly except that the contact update fires two workflows rules that have already fired and based on the evaluation criteria: "When a record is created, or when a record is edited and did not previously meet the rule criteria". The APEX trigger update does not update any of the fields referenced in the workflows' criterias. I tried to replicate the problem in the org.'s sandbox, but could not. It's as though the apex trigger update is erasing the workflow history that they workflow has already run. (logically as though trigger.old is not reference or is erased for the workflow). Has anyone experienced this issue before or has any idea of why this would be occuring besides a Salesforce bug?

 

Related code below:

 

Trigger:

trigger ConverttoHouseholdTrigger on Contact (before insert, before update) {

contactHouseholdFellowship.contactHouseholdFellowshipMethod(trigger.new);

}

 

CLASS:

 

public class contactHouseholdFellowship
{
    public static void contactHouseholdFellowshipMethod(contact[] contacts)
    {   
   //Account - Build a "reversed" record type map for Account so that the record type name becomes the Key 
   //and the id is the Value.
    Map<String, Id> AccountRecTypesRev = new Map<String, Id>();
    for(RecordType rec :[select id, DeveloperName, sObjectType from RecordType 
    where sObjectType = 'Account']) {
        AccountRecTypesRev.put(rec.DeveloperName, rec.Id); }
       
    id HHaccRec = AccountRecTypesRev.get('Household');
 
    list<contact>contactList = new list<contact>();
    list<account>accountList = new list<account>();
    set<id>contactSet = new set<id>();
    map<id,id>accountMap = new map<id,id>();
    map<id,id>contactMap = new map<id,id>();
    
    for (contact c : contacts)
        {
        contactset.add(c.id);    
        }    
     
    //Contact list is necessary because we can't obtain parent 'account' field values without a SOQL query
    contactList = [select id, name, firstName, LastName, account.recordtypeId, email, Do_Not_Mail__c, 
    HasOptedOutOfEmail,DoNotCall,HomePhone,Phone,MailingStreet,MailingCity,MailingState,MailingPostalCode,
    OtherStreet,OtherCity,OtherState,OtherPostalCode,Fellowship_Status__c
    from contact where id in : contactSet];
    
    for (contact c : contactList)
        {  
        //only if contact is not already the child of a 'Household' account and only if 'offer Accepted' as
        //per current related workflow rule criteria
        if (c.account.recordTypeId != HHaccRec && c.Fellowship_Status__c == 'Offer Accepted')
            {   
            //Create map for contacts to be updated for contact.accountid update below
            contactMap.put(c.id,c.id);        
            account account = new account();
            account.name = c.firstname + ' ' + c.lastName + ' Household';
            account.Addressee__c = c.firstname + ' ' + c.lastName;
            account.Addressee_Informal__c = c.firstname;
            account.Email__c = c.Email; 
            account.Do_Not_Mail__c = c.Do_Not_Mail__c;
            account.Do_Not_Email__c = c.HasOptedOutOfEmail;
            account.Do_Not_Call__c = c.DoNotCall;
            account.recordtypeid = HHaccRec;
           If (c.HomePhone != null) 
               {
               account.phone = c.HomePhone; 
               }
               else 
               {
               account.phone = c.Phone; 
               }
             account.BillingStreet = c.MailingStreet;
             account.BillingCity = c.MailingCity;
             account.BillingState = c.MailingState;
             account.BillingPostalCode = c.MailingPostalCode;
             account.ShippingStreet = c.OtherStreet;
             account.ShippingCity = c.OtherCity;
             account.ShippingState = c.OtherState;
             account.ShippingPostalCode = c.OtherPostalCode;
             //set primary contact record for household account
             account.Primary_Contact__c = c.id;
             accountList.add(account);                                     
             }
         }  
         insert accountList;
         
         //map primary contact id to account id so we can reference which account the contact 
         //should be updated to via the parent/child account/contact relationship
         for (account a : accountList)
             {
             accountMap.put(a.Primary_Contact__c, a.id);
             }
         
     for (contact c: contacts)
         {
         //only update contacts that fit the criteria for the contactList
         if (contactMap.get(c.id) != null)
             { 
             c.accountid = accountMap.get(c.id);            
             }
         }         

     }     

 

 

Hi, I have installed the 'ideas' base theme and everything is working correctly via Force Sites except for that the 'search community' form is calling the visualforce link instead of the sites link. For example, when I click on the magnifying glass image next to the input box, it calls '/apex/ideaSearchResults?s=' instead of the correct '/ideaSearchResults?s='. This appears to be related to the 'ideaSecondary' VF component and the 'IdeaController' class. This class has the following variable: private static final String PAGE_PREFIX = '/apex'.

 

Thanks,

 

Tanner

 

 

Hi everyone,

 

Does anyone have any experience/example code with setting a sites page to function as a listener/handler for an http POST?  

 

Thanks! 

Hi everyone,

 

I have created a visualForce page that has a couple "<apex:inputField>" for the 'campaign' object. When I view the VF page directly in Salesforce, it appears correct with the input box. But when I view it via 'Sites', the input area/box is not displaying as though the fields are 'read only'.  I assumed it was an issue with 'field security' and the guest user profile but the fields are set to 'editable'. I also verified that 'view' and 'create' were checked for the 'Standard Object Permissions' for the profile. I tested it with other objects and only campaigns seems to be an issue?

 

Here is the sites page:

 

http://icbeta1-developer-edition.na2.force.com/

http://icbeta1-developer-edition.na2.force.com/ 

 

 

Fields:

 

<apex:inputField id="inputValue" value="{!campaign.startDate}"/>

<apex:inputField id="inputValue2" value="{!campaign.isactive}"/>

 

Thanks ahead of time! 

 
Page code: 

 

 

    <apex:page standardcontroller="Campaign">
    <apex:form >
<apex:pageBlock title="School Recruiter Events">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Event Details" columns="2">
<apex:inputField id="inputValue" value="{!campaign.startDate}"/>
<apex:inputField id="inputValue2" value="{!campaign.isactive}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Hi everyone, 

 

Quick question. Is the owner/creator of a record via an 'insert' DML statement based on the owner of the APEX class that is creating the record?  Is there anyway to specify the owner/creator explicity? 

 

Thanks! 

When creating a variable from an SOQL query, it appears to be necessary to verify that there is a value to match up with the variable before trying to assign the value to it.  
 
For example, if I utilize the following code:
 workshopLeadRTID = [Select Id from RecordType where SobjectType='lead' and Name=:'Workshop Lead'].id; 
If no value is found via the SOQL query, I receive a runtime error when what I want is to have no value assigned to the variable without the error. Therefore I normally run two queries below:
 
//determine if a value is found based on the query
integer workshopLeadRTID_count = [Select count() from RecordType where SobjectType='lead' and Name=:'Workshop Lead'];
 
//if a value is found, assign it to the variable.  
  if (workshopLeadRTID_count > 0)
  {
  workshopLeadRTID = [Select Id from RecordType where SobjectType='lead' and Name=:'Workshop Lead'].id; 
  }
 
It seems to me that there must be a better way of doing this that I am not seeing to avoid having to do 2 SOQL queries instead of just 1. Any suggestions? thanks! 

The method works via a "after insert" trigger but I receive the following error trying to "after update": 

 

Apex trigger autoLeadConvertTrigger caused an unexpected exception, contact your administrator: autoLeadConvertTrigger: execution of AfterUpdate caused by: System.DmlException: ConvertLead failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, autoLeadConvertTrigger: execution of AfterUpdate caused by: System.DmlException: ConvertLead failed. First exception on row 0; first error: CANNOT_UPDATE_CONVERTED_LEAD, cannot reference converted lead Class.autoLeadConvert.ConvertLead: line 100, column 3 Trigger.autoLeadConvertTrigger: line 14, column 7: Class.autoLeadConvert.ConvertLead: line 100, column 3

 

The main note of importance is the "CANNOT_UPDATE_CONVERTED_LEAD" error. The reason I'm doing an after update instead of after insert is to be able to have the workflow / auto-response rules run before conversion. (workflow / auto-response rules execute after triggers). 

 

What I don't understand is why this is not working for the "after update" trigger. The error appears to be coming from the leadConvert method trying to update the convert lead record fields such as: setContactId, etc.  This doesn't seem to make sense though as to why it would work in the 'after insert' trigger. 

 

Here is the basics of my code:

 

public static void ConvertLead(lead[] leads){

 

for (lead l : leads){

 

account Account = new account();

contact Contact = new contact();

 

//convert lead

converter.setLeadId(l.id);

converter.setContactId(contact.id);

converter.setAccountId(account.id);

converter.setOwnerId(l.OwnerId);

LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1]; converter.setConvertedStatus(convertStatus.MasterLabel);

converter.setDoNotCreateOpportunity(true);

Database.ConvertLead(converter);

 

The apex documentation states the following in regards to considerations for trigger context variables:

 

Can update original object using an update DML operation: 

 

Trigger Event: After Insert 

"Allowed"  

 

Trigger Event: After Update

"Allowed. Even though a bad script could cause an infinite recursion doing this incorrectly, the error would be found by the governor limits." 

 

I know I'm not running governor limits so I'm a missing something or is this a SF bug?

 

Thanks ahead of time! 

 

 

Message Edited by IC-Tanner on 02-25-2009 12:33 PM
Does anyone know if there is a 'contains' logic apex operator? I have a multipicklist that I want to utilize 'contains' logic on. For example (psuedocode):
 
contact c = new contact();
if (c.multiPickList contains 'textvalue') {}
 
//'textvalue' in this case would be a multipicklist option
 
the standard equals operator == doesn't really work here as the multipicklist field functions like a text string and places all the values selected together as one string. Therefore I have no way of checking if a value is contained by the mulitpicklist unless it is the only option selected.
 
Thanks ahead of time if anyone knows a workaround for this.
 
 
Hi everyone, I was trying to deploy a visualforce apex controller class yesterday and obtained 79% code coverage while testing. When I went to deploy the class in Eclipse, I received errors relating to what appear to be SF system classes, and other classes/triggers I have already installed. Its as though there is an adidtional requirement that the new class provides test coverage for previously installed classes/triggers.  Any ideas to why these errors are displayed and why I am unable to install the class? Here is the error screen shot:
 


Message Edited by IC-Tanner on 10-23-2008 02:34 PM

Message Edited by IC-Tanner on 10-23-2008 02:35 PM
I wanted to create a Case Close Page Layout today and noticed that the current Case Close Page Layouts are not shown in the IDE via Eclipse. All other page layouts for standard and custom objects are shown as well as regular "Case Page Layouts"? Can you anyone know why or if the "Case close page Layouts" are just not accessible via the IDE? What I wanted to do was simply create a copy of a "case page layout" for the "Closed Case page layouts" since you cannot clone a "Closed Case page layouts" directly from a "case page layout" via the standard Salesforce interface.

Thanks ahead of time!
I have a managed package in which a boolean variable is defined as global. When I try to access the variable (via another org. in which the package is installed in) via a VF page, I recieve the following error: Variable is not visible:. I have another boolean variable in the same controller class that is also global and is accessible in a VF page. Therefore I don't understand why the new variable wouldn't be accessible. I've verified that I have the most recent version of the package installed (with parameter set to Global (not in previous package versions)). It appears to me that this is a SF bug because the other variable (defined in the same way) is accessible. 

Has anyone seen a 'new component' issue before for a 'summary layout' component (for a patch version)?  I'm assuming it was something added in Summer '12 as I haven't been able to determine what a 'summary layout' component is. It seems that something was added in Summer '12 that is going to force me to do a major release instead of being able to release a patch version. When I click on the links to the components, I just receive an 'Insufficient Privileges' message. My thought is that is related to the 'Highlights Panel' of Page Layouts though I thought this was added in Summer '11. 

 

Thanks!

 



 

 

 I am trying to bulk a trigger but have run into issues with the normal set/map method and therefore cannot figure out how to bulk the trigger. 
Quick background:
-before 'lead' object insert, query 'AFS_Zip__c' object to determine what the 'area team' is for the lead based on the lead's postal code referenced against a postal code range on the 'AFS_Zip__c'' object. 
-Normally I would just add all the 'trigger.new' postal codes to a set, then run one SOQL query to obtain all the 'area team' field values from the 'AFS_Zip__c' object based on 'in' set.  Because the 'AFS_Zip__c'' object provides a range of postal codes per 'area team', 'in' doesn't work. I therefore tried to add all the 'AFS_Zip__c' object'object records to a map but ran into  the '1000 record limit on SOQL queries per trigger'. because the 'AFS_Zip__c' object contains 4000+ records. 
Working code but not bulkified:
trigger TrgIns_SetDefaultValues on Lead (before insert,before update) 
{
    integer IsATFound;
    
    IsAtFound = 0;  
    
    for(Lead lead : trigger.new)    
    {       
        for (AFS_Zip__c az : [Select Name from AFS_Zip__c az where az.FromZip__c <= :lead.PostalCode and 
             az.ZipTo__c >= :lead.PostalCode]) 
        { 
            lead.Area_Team__c = az.name; 
            IsATFound = 1;  
        }//close for AFS_zip 
          
        if (IsATFound == 0) 
        { 
            lead.Area_Team__c = 'Un-Repped'; 
        }            
    }    
}

updated code that is running into '1000 record limit on SOQL queries per trigger' limit:
trigger TrgIns_SetDefaultValues_beta on Lead (before insert,before update) 
{
    map<string, string> zipMap = new map<string,string>();
     
    //creates lists of 'AFS_Zip__c' records. Issue is that the total query records size returned is 4000+
    
    for(list<AFS_Zip__c> zipList : [select id, name, FromZip__c, ZipTo__c from AFS_Zip__c])
    {    
        //for each 'AFS_Zip__c' record, determine upper and lower postal code values and 
        //map each value in the range to the 'name' field
        for (AFS_Zip__c zip : zipList)
        {         
            for(integer zipValue = integer.valueOf(zip.FromZip__c); zipValue <= integer.valueOf(zip.ZipTo__c); zipValue++)
            {
                zipMap.put(string.valueOf(zipValue), zip.name);      
            }       
        }
    }      
    
    for(Lead lead : trigger.new)    
    { 
        //if lead zip code is found in the map (~'AFS_Zip__c' postal code range'), then update the lead 'Area_Team__c 
        //field. If not, update it as 'Un-Repped'
        if(zipMap.containsKey(lead.PostalCode))
        {
            lead.Area_Team__c = zipMap.get(lead.PostalCode);
        }
        else
        {
            lead.Area_Team__c = 'Un-Repped'; 
        }  
    }   
}
------------------------------------------
Logically, I need to determine a means of only querying/mapping for the 'postal code' values from the 'trigger.new' but can't determine a method to do this because of the range. I thought about using custom settings to get around the SOQL record limits but the range check doesn't seem possible via the custom settings methods (getAll(), etc.) without using SOQL. 
Any suggestions would be greatly appreciated. Thanks!!

 

 

I tried to deploy a non 'Chatter' related Apex class & trigger today and received the following error fired by a the test method of the chatterConnector Class. Because the Chatter APEX classes/triggers are not part of a managed package, the chatter test methods are firing for my unrelated code. Therefore I cannot deploy, update, or delete any APEX classes/triggers which is a major issue. Salesforce, can you please update this test method or allow unpackaged classes/triggers to be deployed without calling the Chatter test methods?

 

Feel free to contact me directly with any database instance specific questions.

 

Thank you!

 

Related info from Debug log:

 

17:45:6.650|EXECUTION_STARTED

17:45:6.650|CODE_UNIT_STARTED|[EXTERNAL]chatterConnector.main

17:45:6.653|METHOD_ENTRY|[15,50]|MAP:String,String.get(String)

17:45:6.653|METHOD_ENTRY|[15,34]|System.PageReference.getparameters()

17:45:6.653|METHOD_ENTRY|[15,10]|ApexPages.currentpage()

17:45:6.653|METHOD_EXIT|[15,10]|currentPage()

17:45:6.653|METHOD_EXIT|[15,34]|getParameters()

17:45:6.653|METHOD_EXIT|[15,50]|get(ANY)

17:45:6.653|METHOD_ENTRY|[26,9]|chatterConnector.buildUserList()

17:45:6.653|SOQL_EXECUTE_BEGIN|[77,19]|Aggregations:0|select id, name, userroleid, profileid, department, state, country,

            managerid, manager.name, manager.managerid, manager.manager.managerid, manager.manager.manager.managerid, manager.manager.manager.manager.managerid

            from User

            where id = :Userinfo.getUserId()

17:45:6.661|METHOD_ENTRY|[80,25]|Userinfo.getUserId()

17:45:6.661|METHOD_EXIT|[80,25]|getUserId()

17:45:6.671|SOQL_EXECUTE_END|[77,19]|Rows:1|Duration:18

17:45:6.672|METHOD_ENTRY|[84,23]|integer.valueof(String)

17:45:6.672|METHOD_EXIT|[84,23]|valueOf(String)

17:45:6.674|METHOD_ENTRY|[89,79]|UserInfo.getUserId()

17:45:6.674|METHOD_EXIT|[89,79]|getUserId()

17:45:6.678|METHOD_ENTRY|[137,24]|Database.query(String)

17:45:6.681|SOQL_EXECUTE_BEGIN|[137,24]|Aggregations:0|select id, name, managerid, title, city, state, department, createddate from User where isactive = true and usertype = 'Standard' and id <> '00550000000ymonAAA'  limit 1000

17:45:6.685|SOQL_EXECUTE_END|[137,24]|Rows:41|Duration:4

17:45:6.685|METHOD_EXIT|[137,24]|query(String)

17:45:6.685|SOQL_EXECUTE_BEGIN|[141,45]|Aggregations:0|select id, subscriberid

            from EntitySubscription

            where subscriberid IN :uList

            and parentid = :UserInfo.getUserId()

17:45:6.699|METHOD_ENTRY|[144,29]|UserInfo.getUserId()

17:45:6.699|METHOD_EXIT|[144,29]|getUserId()

17:45:6.710|SOQL_EXECUTE_END|[141,45]|Rows:0|Duration:25

17:45:6.711|SOQL_EXECUTE_BEGIN|[152,44]|Aggregations:0|select id, parentid

            from EntitySubscription

            where subscriberid = :UserInfo.getUserId()

            and parentid IN :uList

17:45:6.715|METHOD_ENTRY|[154,35]|UserInfo.getUserId()

17:45:6.715|METHOD_EXIT|[154,35]|getUserId()

17:45:6.725|SOQL_EXECUTE_END|[152,44]|Rows:1|Duration:14

17:45:6.725|METHOD_ENTRY|[160,13]|SET:Id.add(Id)

17:45:6.727|METHOD_EXIT|[160,13]|add(ANY)

17:45:6.727|SOQL_EXECUTE_BEGIN|[163,45]|Aggregations:0|select subscriberid, count(id)

            from EntitySubscription

            where subscriberid IN :uList

            group by subscriberid

            order by count(id) desc

            limit 200

17:45:6.733|SOQL_EXECUTE_END|[163,45]|Rows:21|Duration:6

17:45:6.733|EXCEPTION_THROWN|[163,45]|System.Exception: Too many query rows: 1090

17:45:6.733|METHOD_EXIT|[26,9]|buildUserList()

17:45:6.733|FATAL_ERROR|System.Exception: Too many query rows: 1090

 

Hi, I would like to create an <apex:dataTable> based on the logic of the 'sort="popular"' attribute of the 'ideas:listOutputLink' component. Because the code behind this component is not exposed, I'm unable to determine the query logic utilized for this attribute. I also have been able to determine the logic from reviewing the 'ideas' listed for the ''sort="popular"' attribute via testing. Does anyone know the query logic utilized for the 'sort' attibute and corresponding 'popular' value so that I can replicate it?

 

Thanks!

Today I was trying to deploy a small Apex Trigger from my sandbox to production. Here is the code:

 

 

trigger commentMove on Case (after update) {
  Case myCase = trigger.new[0];
  if (myCase.Last_email__c!= null) {
    String caseId= myCase.ID;
    CaseComment cc = new CaseComment(CommentBody=myCase.Last_email__c,parentID=caseId);
    insert cc;
  }
}

 

 

 

However I got a failed deployment and when I looked at it what failed was:

 

chatterFollowLists.testFollowAllRule()Class1816Failure Message: "System.Exception: Assertion Failed: Expected: 0, Actual: 1", Failure Stack Trace: "Class.chatterFollowLists.testFollowAllRule: line 181, column 6 External entry point"
chatterFollowRules.testFollowEveryone()Class65055

Failure Message: "System.Exception: Too many query rows: 501", Failure Stack Trace: "Class.chatterFollowRules.testFollowEveryone: line 650, column 55 External entry point"

 

I installed the Chatter Follow From List View yesterday. Why would this be failing my Case Apex trigger?

Hi,

 

I would like to be able to show a gif spinner on my visual force page as I am doing something on the background like loading data or waiting for data to come back before I update the page.

 

It will be ideal if I can replace apex:tags with a stylesheet that will be turned off or on based on user click.

 

 

Does anyone have a good solution for that I ma not very ajax savvy per say so any ideas will be appreciated.

 

 


Thank you. 

 

 

  • October 16, 2009
  • Like
  • 0

Hi everyone,

 

Does anyone have any experience/example code with setting a sites page to function as a listener/handler for an http POST?  

 

Thanks! 

Hi everyone,

 

I have created a visualForce page that has a couple "<apex:inputField>" for the 'campaign' object. When I view the VF page directly in Salesforce, it appears correct with the input box. But when I view it via 'Sites', the input area/box is not displaying as though the fields are 'read only'.  I assumed it was an issue with 'field security' and the guest user profile but the fields are set to 'editable'. I also verified that 'view' and 'create' were checked for the 'Standard Object Permissions' for the profile. I tested it with other objects and only campaigns seems to be an issue?

 

Here is the sites page:

 

http://icbeta1-developer-edition.na2.force.com/

http://icbeta1-developer-edition.na2.force.com/ 

 

 

Fields:

 

<apex:inputField id="inputValue" value="{!campaign.startDate}"/>

<apex:inputField id="inputValue2" value="{!campaign.isactive}"/>

 

Thanks ahead of time! 

 
Page code: 

 

 

    <apex:page standardcontroller="Campaign">
    <apex:form >
<apex:pageBlock title="School Recruiter Events">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Event Details" columns="2">
<apex:inputField id="inputValue" value="{!campaign.startDate}"/>
<apex:inputField id="inputValue2" value="{!campaign.isactive}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Does anyone know if you can override the default layout for the lookup page on an object?  I want to add a button to add a new record when needed.  For example, you start a new case on an account, and need to lookup the contact for the case.  The contact at the company has not yet been entered and is not in the lookup dialog.  I want to be able to click Add New to bring up the add new contact page to add it on the fly rather than having to go back and add the contact to the company before starting the case.  Any ideas?

I am attempting to build a site with a Flex .swf in it that is accessing the database via the Flash Connection object provided in your .swc file.  Do I need to call apex.login(new LoginRequest... and if so, what ID and password do I use? 

 

Assuming this is anonymous access, is there a way to use the .swc file you provide without logging in?  Or is access to the database impossible via this mechanism for sites?

 

Thanks!

 

Dave

 

  • March 27, 2009
  • Like
  • 0
When creating a variable from an SOQL query, it appears to be necessary to verify that there is a value to match up with the variable before trying to assign the value to it.  
 
For example, if I utilize the following code:
 workshopLeadRTID = [Select Id from RecordType where SobjectType='lead' and Name=:'Workshop Lead'].id; 
If no value is found via the SOQL query, I receive a runtime error when what I want is to have no value assigned to the variable without the error. Therefore I normally run two queries below:
 
//determine if a value is found based on the query
integer workshopLeadRTID_count = [Select count() from RecordType where SobjectType='lead' and Name=:'Workshop Lead'];
 
//if a value is found, assign it to the variable.  
  if (workshopLeadRTID_count > 0)
  {
  workshopLeadRTID = [Select Id from RecordType where SobjectType='lead' and Name=:'Workshop Lead'].id; 
  }
 
It seems to me that there must be a better way of doing this that I am not seeing to avoid having to do 2 SOQL queries instead of just 1. Any suggestions? thanks! 

The method works via a "after insert" trigger but I receive the following error trying to "after update": 

 

Apex trigger autoLeadConvertTrigger caused an unexpected exception, contact your administrator: autoLeadConvertTrigger: execution of AfterUpdate caused by: System.DmlException: ConvertLead failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, autoLeadConvertTrigger: execution of AfterUpdate caused by: System.DmlException: ConvertLead failed. First exception on row 0; first error: CANNOT_UPDATE_CONVERTED_LEAD, cannot reference converted lead Class.autoLeadConvert.ConvertLead: line 100, column 3 Trigger.autoLeadConvertTrigger: line 14, column 7: Class.autoLeadConvert.ConvertLead: line 100, column 3

 

The main note of importance is the "CANNOT_UPDATE_CONVERTED_LEAD" error. The reason I'm doing an after update instead of after insert is to be able to have the workflow / auto-response rules run before conversion. (workflow / auto-response rules execute after triggers). 

 

What I don't understand is why this is not working for the "after update" trigger. The error appears to be coming from the leadConvert method trying to update the convert lead record fields such as: setContactId, etc.  This doesn't seem to make sense though as to why it would work in the 'after insert' trigger. 

 

Here is the basics of my code:

 

public static void ConvertLead(lead[] leads){

 

for (lead l : leads){

 

account Account = new account();

contact Contact = new contact();

 

//convert lead

converter.setLeadId(l.id);

converter.setContactId(contact.id);

converter.setAccountId(account.id);

converter.setOwnerId(l.OwnerId);

LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1]; converter.setConvertedStatus(convertStatus.MasterLabel);

converter.setDoNotCreateOpportunity(true);

Database.ConvertLead(converter);

 

The apex documentation states the following in regards to considerations for trigger context variables:

 

Can update original object using an update DML operation: 

 

Trigger Event: After Insert 

"Allowed"  

 

Trigger Event: After Update

"Allowed. Even though a bad script could cause an infinite recursion doing this incorrectly, the error would be found by the governor limits." 

 

I know I'm not running governor limits so I'm a missing something or is this a SF bug?

 

Thanks ahead of time! 

 

 

Message Edited by IC-Tanner on 02-25-2009 12:33 PM
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
Does anyone know if there is a 'contains' logic apex operator? I have a multipicklist that I want to utilize 'contains' logic on. For example (psuedocode):
 
contact c = new contact();
if (c.multiPickList contains 'textvalue') {}
 
//'textvalue' in this case would be a multipicklist option
 
the standard equals operator == doesn't really work here as the multipicklist field functions like a text string and places all the values selected together as one string. Therefore I have no way of checking if a value is contained by the mulitpicklist unless it is the only option selected.
 
Thanks ahead of time if anyone knows a workaround for this.
 
 
I wanted to create a Case Close Page Layout today and noticed that the current Case Close Page Layouts are not shown in the IDE via Eclipse. All other page layouts for standard and custom objects are shown as well as regular "Case Page Layouts"? Can you anyone know why or if the "Case close page Layouts" are just not accessible via the IDE? What I wanted to do was simply create a copy of a "case page layout" for the "Closed Case page layouts" since you cannot clone a "Closed Case page layouts" directly from a "case page layout" via the standard Salesforce interface.

Thanks ahead of time!
Pages and static resources cannot be packaged yet.

So, as the final step in our app's install process (after the packageable stuff has been deployed), we use the metadata API to deploy pages and static resources.  We use the declarative metadata calls to deploy zip files, to be precise.

The expected behavior is that this would work fine - the zip file contains no code at all, so code coverage isn't a concern.  The packages should just upload & deploy.

However, we have run into a bug - Salesforce runs the tests for *all* unpackaged code - including things that aren't in the zipfile, and are totally unrelated to our application - and uses the results from those to prevent our deploy from succeeding.

As an example, we deploy a package of static resources.  These are just static files - no code, no tests, just files.

When we deploy those static resources into an org that has downloaded other unmanaged code (in our case, a piece of sample code from Salesforce labs), the deploy call fails because Salesforce runs the tests in that other, unrelated unmanaged code and then declares that our code coverage statistics aren't good enough.  Which doesn't really make sense because we're only deploying some gifs and stylesheets!

I've played with the various "deployOptions" settings but none of them help.  Apparently Salesforce says "hmm, you're deploying unmanaged code.  I guess I'll test all the *other* unmanaged code, and if it doesn't have good enough code coverage, I'll prevent *your* deploy from succeeding."

Here is the final error output in parse format.  I can post the XML too if anyone wants it:

Code:
deploy failed: {
  id => "04s600000004JHKAA2",
  messages => {
    changed  => "true",
    created  => "false",
    deleted  => "false",
    fileName => "resources/package.xml",
    fullName => "package.xml",
    success  => "true",
    },
  runTestResult => {
    codeCoverage     => {
      dmlInfo => { column => 9, line => 66, numExecutions => 1, "time" => "0.0" },
      id => "01p6000000001fPAAQ",
      locationsNotCovered => { column => 9, line => 70, numExecutions => -1, "time" => "-1.0" },
      methodInfo => { column => 37, line => 3, numExecutions => 2, "time" => "179.0" },
      name => "unsubscribe",
      namespace => undef,
      numLocations => 28,
      "numLocationsNotCovered" => 4,
      soqlInfo => { column => 20, line => 53, numExecutions => 1, "time" => "0.0" },
      type => "Class",
      },
    codeCoverageWarnings => {
      id => "01p700000000GCuAAM",
      message => "Average test coverage across all Apex Classes and Triggers is 15%,
 at least 75% test coverage is required", name => undef, namespace => undef, }, numFailures => 0, numTestsRun => 2, successes => { id => "01p6000000001fPAAQ", methodName => "testUnsubscribe", name => "unsubscribe", namespace => undef, "time" => "4.6454630156326666E18", }, totalTime => "955.0", }, success => "false", }

 


  • July 02, 2008
  • Like
  • 0

LeadConvert isn’t considered a valid class in Apex Code.  Database.ConvertLead was released with Winter ’08 but using that call requires you pass in a single LeadConvert object or an array of LeadConvert objects but the compiler doesn’t recognize the class.  I’ve verified that I’m compiling it using the 11.1 URL.

The documentation states that ConvertLead is untested in the Flex API, but I'd like to confirm that it doesn’t work.  I’m getting an error message: “Invalid Lead ID” when I attempt to use it.  I’ve tried with 15 and 18 character IDs and verified that every ID being passed (account, contact, lead, owner) are all valid.  The Ids themselves are pulled directly from SFDC via the API using the same session the browser.   I’ve verified the whole process by stepping through it in the Flex debugger but without digging through the Flex API source directly I’m not sure what the issue is.

Here’s sample Flex code that’s failing, along with the error message:

Error:

Message:            valid leadId is required
statusCode:        INVALID_CROSS_REFERENCE_KEY

 Code:

private function convertSingleLead( leadId:String, accountId:String, contactId:String, ownerId:String ):void
{
      var converter:LeadConvert = new LeadConvert;
      
      converter.accountId = accountId;
      converter.contactId = contactId;
      converter.doNotCreateOpportunity = true;
      converter.overwriteLeadSource = true;
      converter.convertedStatus = “Closed – Converted”;
      converter.ownerId = ownerId;
      converter.leadId = leadId;

      apex.convertLead( new Array( converter ), new AsyncResponder( postConversion, sfdcCallFailed ) );
}

Thanks,

  • January 29, 2008
  • Like
  • 0