function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AdiiAdii 

how to do this trigger scenerio???

Create a new custom field of type checkbox on account,contact and lead named as ‘SDR Credit’ and new number field ‘Number of SDR Contacts/Leads’ on account and lookup field for Account named as ‘Matching Account’ on leads. So the logic here is that whenever a task under a contact/lead is created with type ‘Call’ and another task of type ‘Meeting’ is logged under same contact/lead within 180 days o
Best Answer chosen by Adii
ANUTEJANUTEJ (Salesforce Developers) 
Hi Adii,

>> To create field you can go into setup navigate to the object and create new fields of the necessary types.

>> Create a trigger with before insert and then iterate through each record in trigger.new to see if the record satisfies a condition and in case if it satisfies you can create a new task with the values to the fields and add them to a list and insert the whole list after ending the for loop.

I hope this helps and in case if it does come in handy can you please choose this as best answer so that it can be used by others in the future.

Regards,
Anutej

All Answers

ANUTEJANUTEJ (Salesforce Developers) 
Hi Adii,

>> To create field you can go into setup navigate to the object and create new fields of the necessary types.

>> Create a trigger with before insert and then iterate through each record in trigger.new to see if the record satisfies a condition and in case if it satisfies you can create a new task with the values to the fields and add them to a list and insert the whole list after ending the for loop.

I hope this helps and in case if it does come in handy can you please choose this as best answer so that it can be used by others in the future.

Regards,
Anutej
This was selected as the best answer
AdiiAdii
so in this how we know that task is created on which contacts or leads???
how wo know this?
 
ANUTEJANUTEJ (Salesforce Developers) 
So the trigger gets called whenever a new record gets created under the object we can ensure the contact by using the context variables.

As you would be using the ui to go to task under a contact  record the new task that is created via ui would be directly attached to the contact however in case if you are creating via trigger then you will have to give the whoid to associate a task to a contact.

I hope this helps
AdiiAdii
thanks  sir I am doing this trigger ...if i m facing any error then i msg here
 
SSP AdminSSP Admin
Hello Adii

It looks like our team of experts can help you resolve this ticket. We have Salesforce global help-desk support and you can log a case and our Customer Success Agents will help you solve this issue. You can also speak to them on live chat. Click on the below link to contact our help-desk. Trust me it is a support service that we are offering for free!

https://jbshelpdesk.secure.force.com

Thanks,
Jarvis SFDC team
ANUTEJANUTEJ (Salesforce Developers) 
Hi Adii,

I hope you were able to achieve the scenario with a trigger, in case if the above details helped can you please mark the useful comment as best answer so that the others that are facing the issue would find the details useful in the future.

Regards,
Anutej