+ Start a Discussion
Nasif HasnainNasif Hasnain 

need help in trigger

I need to write a trigger for the below requirement:

If a record is inserted in an object phone with name iphone and colour red, then trigger should insert iphone with all the availaible colour- black blue orange and so on

There were 10 colour present in as metadata with name colour, so trigger should create iphone with all the remaining colour except red.
AkshaySFDCAkshaySFDC
As per my understanding, You want to insert Phone with name iPhone only when color is not red. Am I right in my understanding?
Nasif HasnainNasif Hasnain
no, it should insert with red as well as with all the colour present
If iphone is getting inserted with red, then trigger should insert for all the other colour variant like-

iPhone     black
iphone   green

iphone    orange as well as red………………….


Custom metadata consists all the colours (black, green, orange and red)
 
Steve Schreiner 4Steve Schreiner 4
Just insert them all, regardless of the color specified. That is, if you are inserting all of them anyway, it doesn't matter what color the initial iPhone was supposed to be. Create them all, a record for each color, with the same name, add them to a list, then insert the list.
Nasif HasnainNasif Hasnain
ok.. i am new to trigger can you please write it, so it will be easy for me to understand and it will be like

iphone_red        red

iphone_black      black

iphone_orange   orange and so on...

Thank you