• Marmot74
  • NEWBIE
  • 0 Points
  • Member since 2009

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

Is it possible using a VisualForce page to display account fields on the contact page layout? I don't really want to create a bunch of forumla fields to do this.

 

Thanks

 

Hey Guys, I have the following trigger that basically updates the account table when certain data criteria is met in a custom table. This is a one-many relationship and they relate via AccountId. It errors out with "Too many script statements: 50001". Please help with better logic.

trigger OnLicense_UpdateIsSupported on Licenses__c (after insert, after undelete, after update) { Set<String> AccountIDs = new Set<String>(); List<Account> updAccounts = new List<Account>(); for(Licenses__c Lic : trigger.new){ if(!AccountIDs.contains(Lic.Account__c)) AccountIDs.add(Lic.Account__c); } List<Account> Accounts = [SELECT ID, IsSupported__c, Is_Customer__c FROM Account WHERE ID IN :AccountIDs]; List<Licenses__c> lics = [SELECT Account__c, Expire_Date__c FROM Licenses__c WHERE Account__c IN :AccountIDs AND Active__c = true AND IsDeleted = false]; for(Account a : Accounts){ a.Is_Customer__c = false; a.IsSupported__c = false; for(Licenses__c l : lics){ if(l.Account__c == a.Id) { a.Is_Customer__c = true; if(l.Expire_Date__c >= Date.Today()) { a.IsSupported__c = true; } } } updAccounts.add(a); } update UpdAccounts; }

 

 

hey Guys,

 

I've got a simple Trigger and a Test Class but for some reason I am only getting 77% test coverage. I am trying to understand why. It complains that lines 15 & 16 are not covered. Can someone explain why? I marked them below.

 

Heres the trigger.

trigger OnEFO_CreateContact on Contact (before insert, before update) { Set<String> conOrg_IDs = new Set<String>(); for(Contact Con : trigger.new){ if(Con.Org_ID__c != null && Con.AccountID == null){ conOrg_IDs.add(Con.Org_ID__c); } } List<Account> Accounts = [SELECT Org_ID__c, ID FROM Account WHERE Org_ID__c IN :conOrg_IDs]; for(Contact Con : trigger.new){ for(Account a : Accounts){ if(Con.Org_ID__c == a.Org_ID__c){ //Line 15 Con.AccountID = a.ID; //Line 16 } } } }

 

 

Heres the Test Class.

 

@isTest private class ContactTestClass { static testMethod void TestContact() { String checkid; Contact contact = new Contact(); contact.FirstName = 'Jane'; contact.LastName = 'Smith'; contact.Org_ID__c = '12345'; try{ insert contact; checkid=contact.id; }catch(DMLException e){ system.assert(false,'ERROR INSERTING CONTACTS:' + e.getDMLMessage(0)); } Contact upcontact = [SELECT AccountID FROM Contact WHERE Id = :checkid]; upcontact.FirstName = 'John'; upcontact.Org_ID__c = '12345'; try{ update upcontact; }catch(DMLException e){ system.assert(false,'ERROR UPDATING CONTACTS:' + e.getDMLMessage(0)); } } }

 

 

Hey Guys,

 

I am new to this. What is wrong with the trigger below? is the logic totally out of wack? I updates the AccountID field on Contact based on a query from the Account table using an ExternalID field. No errors, it just doesn't update the AccountID.

 

trigger OnEFO_CreateContact on Contact (before insert, before update) { Set<String> conOrg_IDs = new Set<String>(); for(Contact Con : trigger.new){ if(Con.Org_ID__c != null && Con.AccountID == null){ conOrg_IDs.add(Con.Org_ID__c); } } Map<String,Account> AccountMap = new Map<String,Account>([SELECT Org_ID__c, ID FROM Account where Org_ID__c IN : conOrg_IDs]); for(Contact Con : trigger.new){ if(AccountMap.containsKey(Con.Org_ID__c)){ Con.AccountID = AccountMap.get(Con.Org_ID__c).ID; } } }

 

Is there a way to generate an ID simular to newid() in SQL in SFDC?

Hey Guys, I have the following trigger that basically updates the account table when certain data criteria is met in a custom table. This is a one-many relationship and they relate via AccountId. It errors out with "Too many script statements: 50001". Please help with better logic.

trigger OnLicense_UpdateIsSupported on Licenses__c (after insert, after undelete, after update) { Set<String> AccountIDs = new Set<String>(); List<Account> updAccounts = new List<Account>(); for(Licenses__c Lic : trigger.new){ if(!AccountIDs.contains(Lic.Account__c)) AccountIDs.add(Lic.Account__c); } List<Account> Accounts = [SELECT ID, IsSupported__c, Is_Customer__c FROM Account WHERE ID IN :AccountIDs]; List<Licenses__c> lics = [SELECT Account__c, Expire_Date__c FROM Licenses__c WHERE Account__c IN :AccountIDs AND Active__c = true AND IsDeleted = false]; for(Account a : Accounts){ a.Is_Customer__c = false; a.IsSupported__c = false; for(Licenses__c l : lics){ if(l.Account__c == a.Id) { a.Is_Customer__c = true; if(l.Expire_Date__c >= Date.Today()) { a.IsSupported__c = true; } } } updAccounts.add(a); } update UpdAccounts; }