Account acc = new Account();
acc.name = 'test';
insert acc;
Profile p = [SELECT Id FROM Profile WHERE Name = 'System Administrator'];
User u = new User(
Alias = 'testu',
Email = 'test@ensors.com',
EmailEncodingKey = 'UTF-8',
LastName = 'Kulak',
LanguageLocaleKey = 'en_US',
LocaleSidKey = 'en_US',
TimeZoneSidKey='America/Los_Angeles',
ProfileId = p.Id,
UserName='test'
);
INSERT u;
Opportunity opp = new Opportunity();
opp.Account = acc;
opp.name = 'test';
opp.StageName = 'Stage 1 - Qualified';
opp.CloseDate = Date.today();
opp.Owner = u.id;
insert opp;
[SalesForce] Compile Error: Illegal assignment from Id to User
Related Topic
- [SalesForce] “Required fields are missing: [ProfileId]: [ProfileId]” when running Apex Class Test for ChatterAnswersAuthProviderRegTest
- [SalesForce] SOQL returning org data in test class. Not using isTest(SeeAllData=true)
- [SalesForce] Illegal assignment from String to Account
- [SalesForce] Illegal assignment from void to String
Best Answer
Here
this should be