You need to sign in to do that
Don't have an account?
Dhananjay Patil 12
Need a help to create a trigger..
Hello,
My configure with Outlook.when i add an email from outlook to salesforce then the task is created on a perticular contact which is the existing functionlity of application.
there is workflow rule we are using here,
Workflow Rule: ABCUpdate ~ Salesforce - Unlimited Edition
AND( ISPICKVAL(Owner:User.BusinessUnit__c ,"ABC"), $User.BypassWorkflow__c = FALSE, ISPICKVAL( BusinessUnit__c,""))
then we are updating a field "BusinessUnit__c " with value as ABC
this value is updated as soon as task is created.
Now as currently WF rule doesn't trigger when task is craeted via outlook which is a bug in salesforce.
I need to create a trigger for this.
Can someone help me how to create a trigger when i add an email from outlook to salesforce,in the task,it should update the field "BusinessUnit__c " with value as ABC
It would be better if is explain with code example as I am new in apex coding.
My configure with Outlook.when i add an email from outlook to salesforce then the task is created on a perticular contact which is the existing functionlity of application.
there is workflow rule we are using here,
Workflow Rule: ABCUpdate ~ Salesforce - Unlimited Edition
AND( ISPICKVAL(Owner:User.BusinessUnit__c ,"ABC"), $User.BypassWorkflow__c = FALSE, ISPICKVAL( BusinessUnit__c,""))
then we are updating a field "BusinessUnit__c " with value as ABC
this value is updated as soon as task is created.
Now as currently WF rule doesn't trigger when task is craeted via outlook which is a bug in salesforce.
I need to create a trigger for this.
Can someone help me how to create a trigger when i add an email from outlook to salesforce,in the task,it should update the field "BusinessUnit__c " with value as ABC
It would be better if is explain with code example as I am new in apex coding.
Hi Dhananjay,
This is a lot simpler to do than the question here: https://developer.salesforce.com/forums/ForumsMain?id=906F000000095HT as it looks like you do not need to do anything with the who or what Id, you're just trying to update the task if the task comes over from Salesforce for Outlook.
We had a requirement when a email was logged by Salesforce for Outlook and it the subject started with "RE: " we wanted to update another field on the task to show it was a responded email.
You can keep in a simple before insert trigger like this (be sure to add any standard error handling that you need):
And the class would look something like this:
However, have you considered using a formula field? It looks like you're only trying to pull in information off of the user record. You can use something like this for the formula - but no code involved!
Hope this helps,
Kelly
All Answers
One thing fiest you need to check what is your Evaluation Criteria .if it is created -then you can write trigger with event before insert .
If it i screated and edited then you need to write trigger for both insert and update .
If it is created and edited and subsequiently meet the criteria the you need to write in both insert and update and also you need to check old value and new value are not same in update .
After that based on your entry criteri and field update you need to write trigger context .
If you have stil issue post your wf entry criteria and field update detail.
Thanks for the quick response.
Criteria is when user create a contact.In our application every user belongs to some business unit.here Business unit is ABC.in "Task" object we have a picklist field called "Business Unit" which contains Business unit value.
Now If a user 'A' whose business unit is 'ABC' create a contact and provide a valid email address which is configure with outlook.when I add an email from outllok to SFDC,in the perticular contact created by user A,in activity history task is shown.when i drilldown to the task it should display business unit as "ABC" (Because 'A' user belongs to Business Unit ABC )but WF rule is not triiger in case of outlook functionality.but if edit the task and save the task then Business Unit field is getting populated as per the WF rul criteria that I mentioned earlier(Check the bold text).
So here i want to write a trigger in such a way that when I add an email from outlook to SFDC,after creating a task when i drilldown to the task it should populate business unit field automatically..
Hi Dhananjay,
This is a lot simpler to do than the question here: https://developer.salesforce.com/forums/ForumsMain?id=906F000000095HT as it looks like you do not need to do anything with the who or what Id, you're just trying to update the task if the task comes over from Salesforce for Outlook.
We had a requirement when a email was logged by Salesforce for Outlook and it the subject started with "RE: " we wanted to update another field on the task to show it was a responded email.
You can keep in a simple before insert trigger like this (be sure to add any standard error handling that you need):
And the class would look something like this:
However, have you considered using a formula field? It looks like you're only trying to pull in information off of the user record. You can use something like this for the formula - but no code involved!
Hope this helps,
Kelly
For providing this example.I have modified a code a bit and now this working as expected.