Hot answers tagged

9

sObject classes don't implement interfaces at all. Unfortunately, that won't be a viable solution here. One very common solution to this issue (needing to create an object and populate non-writeable fields) is JSON deserialization. It's viable here; an example: LoginHistory l; l = (LoginHistory)JSON.deserialize( '{"UserId": "'+UserInfo.getUserId()+'", ...


5

If you adopt the Enterprise Patterns as defined by Andrew Fawcett, VP at SFDC and formerly CTO of FinancialForce, you will quickly realize the advantage of the underlying principle of separation of concerns into: Service layer Domain layer Selector layer Unit of Work A trigger is merely an entry point to the domain layer and typically is coded as a single ...


5

Your test class isn't performing any inserts. You're guarding your inserts with logic on a field that you don't populate and which is therefore null: Lead l = New Lead(Company = '', FirstName = 'First', LastName = 'Last', leadSource = 'Website', lead_SubType__c = 'Contact Requested'); leadList.add(l); if(l.Referring_Brand_Id__c == '0010H00002SuHKtQAN'){ ...


4

The Resolution! It was a PEBKAC error. But since this is an extremely vague error, I figure I will throw my own experience out. The more instances of this that get thrown out, I figure everyone will have a better grasp of how wide a range, and also how simple an issue can be and still set off this completely erroneous message. That's the main focus here, ...


1

This relationship field bu.Sales_Rep__r will only be populated in your test if: A relationship has been established by some logic that sets the Sales_Rep__c field first The test code then does a query that includes the related object Otherwise bu.Sales_Rep__r will be null resulting in the error you see.


1

Sharing-table records don't have a CreatedDate field. You can query against their LastModifiedDate, if you need to. Remember that, if the RowCause is Manual, those records could have been modified by users or by other functionality since you created them, and other sharing records could have been modified on the same date. The safest approach is to write ...


Only top voted, non community-wiki answers of a minimum length are eligible