Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Retrieve the Account record for which you want to create related
- // Cases and Opportunities
- Account ram = [SELECT Id, Name FROM Account WHERE Name = 'Ram'];
- // Create a related Case. Note that there is a more efficient way to
- // instantiate the Case object than what's shown below. The steps shown
- // below is the "long" but more familiar way for new developers.
- Case ramCase = new Case();
- ramCase.AccountId = ram.Id; // Set the relationship to the Account
- ramCase.Subject = 'Sales Cloud Best Practices';
- insert ramCase;
- // Create a related Opportunity. Depending on your org's configuration,
- // you may need to specify values for other required fields.
- Opportunity ramOpportunity = new Opportunity();
- ramOpportunity.AccountId = ram.Id; // Relate the relationship to the Account
- ramOpportunity.Name = 'Sales Cloud Implementation';
- ramOpportunity.StageName = 'Prospecting';
- ramOpportunity.CloseDate = Date.today();
- insert ramOpportunity;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement