+ Start a Discussion
sandeep bala 2sandeep bala 2 

we have one standard object and one custom object there is no relation ship in those objects but if insert record in custom object then automatically inserted in standard object how can we achieve this.please post this trigger

Best Answer chosen by sandeep bala 2
Dilip_VDilip_V
Hi Sandeep,

Create trigger on custom object.
Trigger CreateRecord On Custom_Obj__C(after insert)
{
List<StanderdObj> Records=new List<StanderdObj> ();
for(Custom_Obj__C Cobj:trigger.new)
{
    StanderdObj SObj=new StanderdObj();
Obj.name=Cobj.name;//Populate required fields
Records.add(SObj);
}
if(SObj.size()>0)
insert Records;
}

Here Custom_Obj__C is your custom object.
        StanderdObj is standard object.

Let me know if you have any issues.

Mark it as best answer if it works.

THanks.

All Answers

Dilip_VDilip_V
Hi Sandeep,

Create trigger on custom object.
Trigger CreateRecord On Custom_Obj__C(after insert)
{
List<StanderdObj> Records=new List<StanderdObj> ();
for(Custom_Obj__C Cobj:trigger.new)
{
    StanderdObj SObj=new StanderdObj();
Obj.name=Cobj.name;//Populate required fields
Records.add(SObj);
}
if(SObj.size()>0)
insert Records;
}

Here Custom_Obj__C is your custom object.
        StanderdObj is standard object.

Let me know if you have any issues.

Mark it as best answer if it works.

THanks.
This was selected as the best answer
sandeep bala 2sandeep bala 2
Thank you
 
sandeep bala 2sandeep bala 2
Tq