In writing a unit test, I have to insert a Journal_c record. Instead of using Ids for several lookup fields, I've run soql queries assuming that the record Ids maybe different from test to production. I am, however, receiving an error when trying to assign both the Product_c and Contact__c fields values via query. The error I receive is "Illegal assignment from LIST to Id. Any help would be appreciated.
Journal__c gift = new Journal__c(); gift.RecordType = [SELECT Id, Name FROM RecordType WHERE SObjectType = 'Journal__c' and Name = 'Class Registration']; gift.Amount_Applied__c = 500; gift.Product__c = [SELECT Id FROM Product__c WHERE Name = 'Gift Certificate']; **Error on this line** gift.Contact__c = [SELECT Id FROM Contact WHERE Name = 'Daniel Mortensen']; **Error on this line** gift.Journal_Type__c = 'Gift Card'; gift.Gift_Certificate_Code__c = 'testcode'; gift.Date__c = system.today(); gift.Status__c = 'Registration'; insert gift;
Oddly enough, the RecordType assignment doesn't error out.