+ Start a Discussion
Kr ramKr ram 

Sample Apex code to link two custom objects which are related using a lookup

Hello gurus,

 

I have this scenario to tackle 

Have two custom objects 

Custom__A

Custom__B

 

both  the custom objects are related using a lookup.

When the user is the custom__B record detail the following needs to be done

 

1)Provide a custom button in Custom__B detail page

2)when the button is clicked from Custom__B page, open a new page with a link to create a new record for custom__A

3)and when the user saves the Custom__A record -associate the Custom__A record with  Custom__B record

 

I know the possible answers are create a custombutton and and a trigger to associate records,

 

Any sample apex examples greatly appreciated.

thanks!