I have created a custom filed in Orders that is a picklist field. On default is pending.
How can I automatically update this field to send when I use the send an email functionality through the activity history?
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityI have created a custom filed in Orders that is a picklist field. On default is pending.
How can I automatically update this field to send when I use the send an email functionality through the activity history?
You will need to write a trigger on the Task
object.
Then you can perform your picklist value change if a Task
object is created where the WhatId
field is an Order
object and the Subject
field begins with 'Email:'
.
trigger TaskTrigger on Task (after insert) {
List<Order> ordersToUpdate = new List<Order>();
for(Task t : Trigger.new) {
if(t.WhatId.getSObjectType() == Order.sObjectType
&& t.Subject.startsWith('Email:')) {
ordersToUpdate.add(new Order(Id = t.WhatId, My_Picklist_Field__c = 'New Value'));
}
}
update ordersToUpdate;
}
)
on line 6, I've corrected it now.
Feb 13, 2015 at 9:45
s
from ordersToUpdate
.
Feb 13, 2015 at 10:05