• John Latimer
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
I created a Trigger to create a New Contact when an Account is created.  I only want the Contact created when a boolean field is True. The Trigger will create the Contact when the if(acc.Diamond_Contractor__c == '1') is commented out, but never creates a Contact if the statement is included.  Am I checking for the field too soon in the Trigger?  Thanks!  John!

trigger CreateAccountContact on Account (after insert, after update){

if(Trigger.isInsert){
    
    List<Contact> ct = new List <Contact>();

    for(Account acc : trigger.new){
if(acc.Diamond_Contractor__c == '1') {
        Contact c = new Contact(LastName = 'User',
                    FirstName = 'Extranet',
                    AccountId=acc.id,
                    Fax=acc.Fax,
                    MailingStreet=acc.BillingStreet,
                    MailingCity=acc.BillingCity,
                    /* similarly add all fields which you want */
                    MailingState=acc.BillingState,
                    MailingPostalCode=acc.BillingPostalCode,
                    MailingCountry=acc.BillingCountry,
                    Phone=acc.Phone);

        ct.add(c);
    }
    insert ct;
}
}
}
I created a Trigger to create a New Contact when an Account is created.  I only want the Contact created when a boolean field is True. The Trigger will create the Contact when the if(acc.Diamond_Contractor__c == '1') is commented out, but never creates a Contact if the statement is included.  Am I checking for the field too soon in the Trigger?  Thanks!  John!

trigger CreateAccountContact on Account (after insert, after update){

if(Trigger.isInsert){
    
    List<Contact> ct = new List <Contact>();

    for(Account acc : trigger.new){
if(acc.Diamond_Contractor__c == '1') {
        Contact c = new Contact(LastName = 'User',
                    FirstName = 'Extranet',
                    AccountId=acc.id,
                    Fax=acc.Fax,
                    MailingStreet=acc.BillingStreet,
                    MailingCity=acc.BillingCity,
                    /* similarly add all fields which you want */
                    MailingState=acc.BillingState,
                    MailingPostalCode=acc.BillingPostalCode,
                    MailingCountry=acc.BillingCountry,
                    Phone=acc.Phone);

        ct.add(c);
    }
    insert ct;
}
}
}
Hi I am looking for a easy way to print or export a large Field Dependency matrix in excel. I am new to saleforce please guide me with complete details.
  • January 30, 2014
  • Like
  • 0