• kryan0618
  • NEWBIE
  • 5 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 8
    Replies
Hi,

I am trying to modify APEX code which pulls Contact Mailing information because we have enabled the State/Country Picklist processing. I get an error message the Code field does not exist??

Example APEX code:
        List<OpportunityContactRole> ocrs = [select ContactId, Contact.AccountId, Contact.Email, Contact.Phone, Contact.Fax, Contact.MailingCity, Contact.MailingCountry, Contact.MailingPostalCode, Contact.MailingStateCode, Contact.MailingStreet, Contact.Name, Id, Role, Opportunity.AccountId, OpportunityId from OpportunityContactRole where opportunityId in :Oppties and role in ('Billing Contact','Shipping Contact')];

All documentation I see says I should be using 'MailingStateCode' to pull the data I want.

This is the error message I receive:
Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger OpportunityBillingContactInfo caused an unexpected exception, contact your administrator: OpportunityBillingContactInfo: execution of BeforeUpdate caused by: System.QueryException: No such column 'MailingStateCode' on entity 'Contact'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.: Class.opportunityHandler.opptyBillingContactInfoHandler: line 9, column 1

Thoughts??
 

I am currently writing APEX code to evaluate web-to-lead information and build a multi-select field on the Lead object based upon the user entries. I would like to know the best practice on how to handle.

I'm a little unsure how to handle concatenation of the values.

Example of a portion of the code:

if(newLeadMap.get(newLeads.get(leadB.email)).Beauty_Blog__c == True) {
leadB.Subscriptions__c = leadB.Subscriptions__c + 'Beauty;';
}
if(newLeadMap.get(newLeads.get(leadB.email)).Entertainment_Blog__c == True) {
leadB.Subscriptions__c = leadB.Subscriptions__c + 'Entertainment;';
}

This works fine if leadB.Subscriptions__c already has a value. However, you cannot concatenate to a null value.

So, my question is... how do I handle if it is null? Do I have to perform a check each time I want to perform the concatenation? Or am I going about this wrong and should be using a different method to build my field?

Thanks in advance!

Is there a way to get to the metadata of the schedule information for reports and/or dashboards via Eclipse? What I would like to be able to do is to search through the metadata for email adresses of users we are going to deactivate. Then I will know which reports and/or dashboards need to be maintained to remove the 'dead' user from. I see the Running User email address in the Report and Dashboard Metadata XML (example below), but I do not see the recipient information.

 

</rightSection>
    <runningUser>first.last@email.com</runningUser>
    <textColor>#000000</textColor>
    <title>DashboardTitle</title>
    <titleColor>#000000</titleColor>
    <titleSize>12</titleSize>
</Dashboard>

 

Thanks!

Hi,

 

I have just created a new trigger to change a field in the Lead object using an AfterInsertUpdate. However, I would now like to update the whole object so all records have a value. How do I go about doing this?

 

Thanks in advance!

 

Hi, I am new to APEX development. I have created a new trigger to update a custom field on the Lead object. I have to use 'after update' since I need to have the OwnerId. It works, however, I just KNOW it is not properly coded. Can someone please review and let me know how it really should be? Especially regarding what is referred to as ‘bulkification’?

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

trigger UpdateLeadOwner2AfterInsertUpdate on Lead (after insert, after update) {

 

string txtLdID;



for (Lead newLead : [Select Id,OwnerId,Lead_Owner_2__c from Lead where Id in :Trigger.new]) {
        
// Update the Lead Record
        txtLdID = newLead.OwnerId;
        if (newLead.Lead_Owner_2__c <> newLead.OwnerId && txtLdID.startsWith('00G') == FALSE) {
          newLead.Lead_Owner_2__c = newLead.OwnerId;
          update newLead;
        }  
              
    }
        
}

Hi,

I am trying to modify APEX code which pulls Contact Mailing information because we have enabled the State/Country Picklist processing. I get an error message the Code field does not exist??

Example APEX code:
        List<OpportunityContactRole> ocrs = [select ContactId, Contact.AccountId, Contact.Email, Contact.Phone, Contact.Fax, Contact.MailingCity, Contact.MailingCountry, Contact.MailingPostalCode, Contact.MailingStateCode, Contact.MailingStreet, Contact.Name, Id, Role, Opportunity.AccountId, OpportunityId from OpportunityContactRole where opportunityId in :Oppties and role in ('Billing Contact','Shipping Contact')];

All documentation I see says I should be using 'MailingStateCode' to pull the data I want.

This is the error message I receive:
Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger OpportunityBillingContactInfo caused an unexpected exception, contact your administrator: OpportunityBillingContactInfo: execution of BeforeUpdate caused by: System.QueryException: No such column 'MailingStateCode' on entity 'Contact'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.: Class.opportunityHandler.opptyBillingContactInfoHandler: line 9, column 1

Thoughts??
 

I am currently writing APEX code to evaluate web-to-lead information and build a multi-select field on the Lead object based upon the user entries. I would like to know the best practice on how to handle.

I'm a little unsure how to handle concatenation of the values.

Example of a portion of the code:

if(newLeadMap.get(newLeads.get(leadB.email)).Beauty_Blog__c == True) {
leadB.Subscriptions__c = leadB.Subscriptions__c + 'Beauty;';
}
if(newLeadMap.get(newLeads.get(leadB.email)).Entertainment_Blog__c == True) {
leadB.Subscriptions__c = leadB.Subscriptions__c + 'Entertainment;';
}

This works fine if leadB.Subscriptions__c already has a value. However, you cannot concatenate to a null value.

So, my question is... how do I handle if it is null? Do I have to perform a check each time I want to perform the concatenation? Or am I going about this wrong and should be using a different method to build my field?

Thanks in advance!

Hi,

 

I have just created a new trigger to change a field in the Lead object using an AfterInsertUpdate. However, I would now like to update the whole object so all records have a value. How do I go about doing this?

 

Thanks in advance!

 

Hi, I am new to APEX development. I have created a new trigger to update a custom field on the Lead object. I have to use 'after update' since I need to have the OwnerId. It works, however, I just KNOW it is not properly coded. Can someone please review and let me know how it really should be? Especially regarding what is referred to as ‘bulkification’?

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

trigger UpdateLeadOwner2AfterInsertUpdate on Lead (after insert, after update) {

 

string txtLdID;



for (Lead newLead : [Select Id,OwnerId,Lead_Owner_2__c from Lead where Id in :Trigger.new]) {
        
// Update the Lead Record
        txtLdID = newLead.OwnerId;
        if (newLead.Lead_Owner_2__c <> newLead.OwnerId && txtLdID.startsWith('00G') == FALSE) {
          newLead.Lead_Owner_2__c = newLead.OwnerId;
          update newLead;
        }  
              
    }
        
}

Hello,

 

i have quick question can we export the reports object data or name of all the report folders by using the data loader.

 

i want to have a excel sheet of all the folder names and reports under that folder in a excel sheet. OR else could you please suggest me any other way to do it.

 

i want this as they are many unwanted reports and reports folders are lying there. So want to do a clean up.

 

Thanks in adavance.