• sfdcIs
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 22
    Replies

my acctMap value is an Account sObject.  I am trying to put the sObject from List<Account> aNewList which is the collection from Trigger.new into this acctMap. How can I do this? I tried with the get.sObjectType method but it's not working

 

acctsMap.put(aOldList.get(i).Id,aNewList.getSObjectType());

 

 

public static void updateContactOptOutSettings(List<Account> aNewList, List<Account> aOldList )
{
for(Integer i = 0; i < aNewList.size(); i++)
{
Map<Id, Account> acctsMap= new Map<Id, Account>();
if ( (aOldList.get(i).Email_Opt_Out__c != aNewList.get(i).Email_Opt_Out__c || aOldList.get(i).Email_Fax_Out__c != aNewList.get(i).Email_Fax_Out__c ||
aOldList.get(i).Do_Not_Call__c!= aNewList.get(i).Do_Not_Call__c ))
{
acctsMap.put(aOldList.get(i).Id,aNewList.getSObjectType());
}
}

I am trying to compare the account recordtype name to the zone record type name from an Account sObject.  If it matches than further processing should be done.  I tried it this way but realzied the hard way that each object have their own record type id. What is the best way to match the record type name?

 

 

List<Zone__c> zList = [select recordtypeid from Zone_c];
List<RecordType> rtList = [select id, name from RecordType ];

 

for(Account a: aList)
{

if( a.recordtypeid ==zList.get(i).recordtypeid )
{

 

// some processing

 

}

I am trying to convert this contact sObject to a string to grab the first 5 characters of the zip and compare but keep getting an error of "method does not exist or incorrect signature. any ideas?

 

String bpc= String.valueOf(c.MailingPostalCode);

 

if(bpc.left(5)>= cList.get(i).zip)

{

 // more processing

}

I have a before insert and update trigger that updates the account.ownerid based on criteria that is met by matching the account.billing state to zone.state__c custom object. I created a try catch block to catch and exception and throw the error to a custom errorlog object.  But it doesn't  seem to catch it. Is this because a query exception is not considered a dml exception? alsoi have A method called getNumDMl(), does this method count all exceptions or just dml ones? I want to basically catch as many exceptions as possible and throw to error log. any advice would be great

 

catch (QueryException e)
{
Error_Log__c eLog = new Error_Log__c();
List<Error_Log__c> eLogList = new List<Error_Log__c>();
for (Integer iex = 0; iex < e.getNumDml(); iex++)
{
eLog.Description__c = e.getDmlMessage(iex);
eLogList.add(eLog);
}
insert eLogList;
}