You need to sign in to do that
Don't have an account?

Got error Invalid initial expression type for field Account.
Code:
Account ac = [select Name from Account where Id= :si.Myne_Account__c]; Opportunity s = new Opportunity(Name = "Hello", Account = ac.Name); insert s;
I Got Error:
Error:
Compile Error: Invalid initial expression type for field Account,
expecting: SOBJECT:Account (or single row query result of that type) |
Why ?
Second, what is the Account you are setting as a parameter in your new opportunity creation? If that is the account that they Opportunity is related to, you should retrieve the id in your SOQL and use the whatid, and set it equal to the id of the account being returned.
if the Account is a custom field on your opportunity, make sure the type you are setting it equal to is the same as the value you are using. (IE text to text, ID to ID, etc.)