You need to sign in to do that
Don't have an account?
sahiti@sfdc
Can anyone breakdown the code and explain
opps.add(new Opportunity(Name=acct.Name + ' Opportunity ' + k, StageName='Prospecting', CloseDate=System.today().addMonths(1), AccountId=acct.Id));
It looks like adding a new opportunity to a list of opportunities. With the line by itself its hard to be 100% but I would say:
opps is a list declared list of opportunities
.add is adding to the list
new Opportunity is the new record of object type Opportunity
Name is the Name field on the opportunity
=acct.Name + ' Opportunity ' + k is setting the value of the name field by using the account Name plus the string Opportunity plus some value k (asuming that acct is an account record somewhere set before the line of code and that k is also set elsewhere)
StageName='Prospecting', field on opportunity set to string value
CloseDate=System.today().addMonths(1) date field on opportunity set to today's date plus one month
AccountId=acct.Id) the AccountId on opportunity set to the account record so that the oppty has a relation to the account.
HTH
Andrew