Skip to content

Instantly share code, notes, and snippets.

@mailtoharshit
Created December 15, 2012 03:08
Show Gist options
  • Save mailtoharshit/4291018 to your computer and use it in GitHub Desktop.
Save mailtoharshit/4291018 to your computer and use it in GitHub Desktop.
trigger OpportunityTrigger on Opportunity(before Update, after Update) {
for (Account acc: Trigger.New) {
//Creating instance of class for each trigger call
OpportunityRecordType art = OpportunityRecordType.getInstance();
......
}
}
public class OpportunityRecordType() {
//Lets add an instance property here
public static OpportunityRecord instance = null;
//public property
public String id {
get;
private set;
}
//public constructor
id = Opportunity.sObjectType.getDescribe().getRecordTypeInforByName().get('Opp').getRecordTypeId();
public static OpportunityRecordType getInstance() {
if (instance == null) {
instance = new OpportunityRecordType();
}
return instance;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment