You need to sign in to do that
Don't have an account?

Iterate over list and create records based on another list
I am having a list of Occupations, Driver, Mechanic, Plumber, Carpenter, Chef.
I have contact records with above occupations. One contact can have multiple occupations too.
So I have a trigger which creates Opportunities with these contacts when another field is updated.
Currently i am creating only one opportunity for each contact, now I am trying to create one opportunity for each contact based on occupation. For instance,
contact 1 - name:contact1,occupation:chef,carpenter
contact 2-name:contact2,occupation:Chef,driver
contact 3 -name:contact3,occupation:driver,mechanic,Plumber
My occupation list contains : Chef,Driver,mechanic
So it should create 5 opportunities( now it creates only 3 opportunities using 3 contacts) like
1.Name-opp1,contact(lookup)-contact1,Contact occ-chef
2.Name-Opp2,contact(lookup)-contact2,contact occu-Chef
3.Name-Opp3,contact(lookup)-contact2,contact occu-driver
4.Name-Opp4,contact(lookup)-contact3,contact occu-Driver
5.Name-Opp5,contact(lookup)-contact3,contact occu-mechanic
I have to iterate over the list of occupations,and create opportunity records.How can i get this change.Thanks all.
I have contact records with above occupations. One contact can have multiple occupations too.
So I have a trigger which creates Opportunities with these contacts when another field is updated.
Currently i am creating only one opportunity for each contact, now I am trying to create one opportunity for each contact based on occupation. For instance,
contact 1 - name:contact1,occupation:chef,carpenter
contact 2-name:contact2,occupation:Chef,driver
contact 3 -name:contact3,occupation:driver,mechanic,Plumber
My occupation list contains : Chef,Driver,mechanic
So it should create 5 opportunities( now it creates only 3 opportunities using 3 contacts) like
1.Name-opp1,contact(lookup)-contact1,Contact occ-chef
2.Name-Opp2,contact(lookup)-contact2,contact occu-Chef
3.Name-Opp3,contact(lookup)-contact2,contact occu-driver
4.Name-Opp4,contact(lookup)-contact3,contact occu-Driver
5.Name-Opp5,contact(lookup)-contact3,contact occu-mechanic
I have to iterate over the list of occupations,and create opportunity records.How can i get this change.Thanks all.
Please try the below code:
If help, mark as solved
Thanks