You need to sign in to do that
Don't have an account?
Eric Blaxton
Trigger to create task and assign to related user during quote approval process
Hi and thanks in advance.
Requirement: I need tips on a trigger to create a task and assign it to a related user on the Quote object. It should happen when a quote enters the intial submittal.
Has anyone done this using Apex or vf?
Regards
Requirement: I need tips on a trigger to create a task and assign it to a related user on the Quote object. It should happen when a quote enters the intial submittal.
Has anyone done this using Apex or vf?
Regards
All Answers
Hi,
I have a requirement,i have two fields in Account and opportunity objects those two are picklist data type one is controlling and another is dependent.if i insert a record in account those two fileds automatically populate in th opportunity before insert and update so that i wrote trigger.The code is below.Can anyone help me to wite test class for this
public with sharing class Opportunity_PopulateVerticalSubvertical extends OpportunityTrigger {
public Opportunity_PopulateVerticalSubvertical(Opportunity[] opportunityOldList, Opportunity[] opportunityNewList) {
super(opportunityOldList,opportunityNewList);
}
public override Boolean executable(Opportunity opportunityOld, Opportunity opportunityNew) {
return true;
}
public override void execute(Opportunity[] opportunityUpdatableList, Boolean forceUpdate) {
if (setting.Disable_Opportunity_UpdateBackEndFields__c == true)
return;
Set<Id> accountIdSet = new Set<Id>();
for (Opportunity oppObj : opportunityUpdatableList) {
accountIdSet.add(oppObj.AccountId);
}
Map<Id,Account> accMap = new Map<Id,Account>([SELECT id,Name,Industry,Sub_IG__c FROM Account WHERE Id in : accountIdSet]);
if(accMap.size() > 0) {
for(Opportunity oppObj : opportunityUpdatableList) {
oppObj.IG__c = accMap.get(oppObj.AccountId).Industry;
oppObj.Sub_IG__c = accMap.get(oppObj.AccountId).Sub_IG__c;
}
}
}
}
Thanks in advance,
Regards,
Rekha
public with sharing class Account_UpdateOpportunityFields extends AccountTrigger {
public Account_UpdateOpportunityFields (Account[] accountOldList, Account[] accountNewList) {
super(accountOldList,accountNewList);
}
public override Boolean executable(Account accountOld, Account accountNew) {
return accountOld.Industry != accountNew.Industry ||
accountOld.Sub_IG__c != accountNew.Sub_IG__c ;
}
public override void execute(Account[] accountUpdatableList, Boolean forceUpdate) {
if (setting.Disable_Account_UpdateOpportunityFields__c == true)
return;
Map<Id,Account> newAccMap=new Map<Id,Account>(accountUpdatableList);
Opportunity [] OpportunityList = [Select IG__c,Sub_IG__c,Allow_Admin_to_Change__c,AccountId from Opportunity where AccountId In:newAccMap.keySet()];
Opportunity [] OpportunityUpdateist = new Opportunity [] {};
for (Opportunity opportunity : OpportunityList) {
if (opportunity.Allow_Admin_to_Change__c == true)
continue;
Account account = newAccMap.get(opportunity.AccountId);
opportunity.IG__c = account.Industry;
opportunity.Sub_IG__c = account.Sub_IG__c;
OpportunityUpdateist.add(opportunity);
}
if(OpportunityUpdateist.size() > 0) {
update OpportunityUpdateist;
}
}
}
Regards,
Rekha