You need to sign in to do that
Don't have an account?
Agi
Trigger to update Opportunity stage from Task subject
i'm looking to update custom picklists on opportunity when a sepcific user is sending an email with specific subject,
there are two user lookups on the opp, when the user in lookup A sends the email and the subject contains X, or user B with subject Y, i'd like a picklist C or D to be updated with a value "in progress"
i found this but i cant modify to meet the above..
trigger TaskSubject on Task (after update, after insert) {
set<id> accountIdSet = new set<id>();
//capture all the subject names in a set
//set<string> subjectName = new set<string>{'financial review','legal precheck'};
map<id, list<opportunity>> opptyMap = new map<id, list<opportunity>>();
list<opportunity> updateOppList = new list<opportunity>();
//get those tasks where the tasks are related to opp, Capture the account IDs in a set.
for(task t: trigger.new){
string tempId = string.valueOf(t.WhatId);
if(tempId.startsWith('006')){
oppIdSet.add(t.whatId);
} }
//If we get the opportunities then change the stage.
if(Trigger.isUpdate && opptyMap.size()>0){
for(task t: trigger.new){
//Check if the subject of the task is one among the set
//and also confirm that the subject has been changed.
if(t.subject != trigger.oldMap.get(t.id).subject && opptyMap.containsKey(t.whatId)){
//iterate thru the list of the opportunity associated with that account
//and check which of the opportunity contains the task subject in the
//opportunity name and update the stage to qualification
for(opportunity oppty: opptyMap.get(t.whatId)){
if(oppty.name.contains(t.subject)){
oppty.stageName='Qualification';
updateOppList.add(oppty);
} } } } }
if(Trigger.isInsert && opptyMap.size()>0){
for(task t: trigger.new){
if(opptyMap.containsKey(t.whatId)){
for(opportunity oppty: opptyMap.get(t.whatId)){
if(oppty.name.contains(t.subject)){
oppty.stageName='Qualification';
updateOppList.add(oppty);
} } } } }
//update the oppties
if(updateOppList.size()>0){
update updateOppList;
} }
there are two user lookups on the opp, when the user in lookup A sends the email and the subject contains X, or user B with subject Y, i'd like a picklist C or D to be updated with a value "in progress"
i found this but i cant modify to meet the above..
trigger TaskSubject on Task (after update, after insert) {
set<id> accountIdSet = new set<id>();
//capture all the subject names in a set
//set<string> subjectName = new set<string>{'financial review','legal precheck'};
map<id, list<opportunity>> opptyMap = new map<id, list<opportunity>>();
list<opportunity> updateOppList = new list<opportunity>();
//get those tasks where the tasks are related to opp, Capture the account IDs in a set.
for(task t: trigger.new){
string tempId = string.valueOf(t.WhatId);
if(tempId.startsWith('006')){
oppIdSet.add(t.whatId);
} }
//If we get the opportunities then change the stage.
if(Trigger.isUpdate && opptyMap.size()>0){
for(task t: trigger.new){
//Check if the subject of the task is one among the set
//and also confirm that the subject has been changed.
if(t.subject != trigger.oldMap.get(t.id).subject && opptyMap.containsKey(t.whatId)){
//iterate thru the list of the opportunity associated with that account
//and check which of the opportunity contains the task subject in the
//opportunity name and update the stage to qualification
for(opportunity oppty: opptyMap.get(t.whatId)){
if(oppty.name.contains(t.subject)){
oppty.stageName='Qualification';
updateOppList.add(oppty);
} } } } }
if(Trigger.isInsert && opptyMap.size()>0){
for(task t: trigger.new){
if(opptyMap.containsKey(t.whatId)){
for(opportunity oppty: opptyMap.get(t.whatId)){
if(oppty.name.contains(t.subject)){
oppty.stageName='Qualification';
updateOppList.add(oppty);
} } } } }
//update the oppties
if(updateOppList.size()>0){
update updateOppList;
} }
Agi
..please help me:)