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
Devendra SawantDevendra Sawant 

Trigger on Account

Hi,

 

I have three objects, Account, Contact, Merge_Account_Contact(It has all the contact fields and one account name field)

When i create new Account and its related Contacts, trigger event should occur and Merge_Account_Contact should be Created.

One account has many contacts. So i am confused how to retrive those values and save into the Merge_Account_Contact.


It would be greate if anyone helps me in writting this trigger.


Thanks in advance.

Cheers,
Devendra S 

dev401hasdev401has

Hi Devendra,

 

I just didnt got your point as to why you want to write a trigger on Account Object.

the new object you say is having all the fields of contact object and one field of Account.

 

You can write a trigger on contact object on insert event. When a new contact is inserted then fetch the record using trigger.new and then check whether it is associated with any account record and if so then insert the values in your new object.

 

I guess this should work fine rather than going for creating a trigger on account object.

Devendra SawantDevendra Sawant

Hi,

 

Yes, i agree with you if i want to work on account and contact.

 

What if i have a another scenario,

 

Four objects namely: Job, Job Task, Schdule Template and Schedule Template Item.

In first relationship Job is Child and ScheduleTemplate is Master where they have lookup relationship.(Job has lookup to Schedule Template)

In second relationship,

Schedule Template (Master) and  Schedule Template Item (Child) : Master-Detail Relationship

When a particular Job is created then i want to save Job Name(which belongs to job) and Schedule Template Item(Schedule Template Items are fetched from Schedule Template) fields into the Job Task object.

One Schedule Template can contain many schedule template items.

How i can write a trigger code to implement this functionality??

 

Cheers,

Devendra S