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
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!