Skip to main content

Questions tagged [fflib]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
2 answers
52 views

Accessing relationship fields in fflib

We are trying to develop our code using fflib. Can we access relationship fields directly in the child domain class or do we need to use the parent object domain to access the field values and sent it ...
Praveen's user avatar
  • 10.1k
0 votes
0 answers
33 views

Accessing relationship fields for setting and filtering using fflib

We are starting to use fflib in our projects. We generally run into disagreements on how we access relationship fields and as well copy values from related fields and set a object field. To set a ...
Praveen's user avatar
  • 10.1k
1 vote
2 answers
110 views

How to mock when calling a factory class

Using below as a dummy example I can mock the service I'm calling, but I think there should be a better way other than I'm doing it when calling a factory class. Any suggestions? Thanks in advance. ...
Andrew L.'s user avatar
  • 857
2 votes
2 answers
177 views

fflib: selector Method query giving me error of Duplicate field selected

I have created following method in my Opportunity selector class. I am passing my query fields dynamically from another class. public List<Opportunity> selectByDynamicFilter(List<String&...
Pj35's user avatar
  • 34
1 vote
2 answers
135 views

Unit testing generating and sending emails with fflib-Apexmocks

I am currently struggling to write a unit test for a method in my domain class, and I'm finding it challenging to understand the logic, especially since I'm new to using the fflib-Apexmocks library. I ...
selman's user avatar
  • 25
0 votes
1 answer
282 views

Mocking a Batch class?

Is there any way to mock a batch class for unit testing and predefine the scope passed to execute method? I am using a selector class method for Database.getQueryLocator at start method. public class ...
selman's user avatar
  • 25
0 votes
1 answer
154 views

SObject type offer__c is not supported by this unit of work

In the project, we use fflib as the Apex enterprise framework. Executing this code: uow.registerDirty(offers); uow.commitWork(); I get this error: The object type offer__c is not supported by ...
EmmanuelP's user avatar
2 votes
1 answer
100 views

fflib CRUD check conflicts with Flow System Context

I have built a simple POC flow Flow - specifically creating and updating an account when the flow is running in System Mode Without Sharing - but using the Experience Cloud Guest Site User. When I run ...
BritishBoyinDC's user avatar
1 vote
1 answer
174 views

Enterprise Architecture, Domain layer - handling multiple records

I'm developing a project using fflib's Enterprise Architecture patterns, based on their example app (https://github.com/apex-enterprise-patterns/fflib-apex-common-samplecode). I am a bit confused ...
mmm321321's user avatar
  • 679
1 vote
1 answer
161 views

Apex Mocks - Verify that child is correctly related to a previously registered parent in Unit of Work

I have code where in the same Unit of Work I'm inserting a record and a related record, for example an Account and Contact. Account acc = new Account(Name = 'Test acc'); unitOfWork.registerNew(acc); ...
Kamil Pilarski's user avatar
0 votes
1 answer
266 views

How do fflib_SObjectDomain methods implement database transactions (trigger context)?

How is fflib applying the default values? I'm working through the Apex Enterprise Patterns: Domain & Selector Layers trailhead module and I'm confused about how database transactions are ...
the-mad-neuroscientist's user avatar
0 votes
0 answers
110 views

Partial mocking using ApexMocks Framework

I want to perform partial mocking using the Salesforce FFLib ApexMocks framework. For example, I have a class like the one below: public class PropertiesServiceImpl implements IPropertiesService { ...
Seleukos2's user avatar
0 votes
1 answer
249 views

fflib_SObjectSelector - Not able to query for RecordType.DeveloperName

So I was going through a selector class and came across an issue: Sample selector class: public List<Schema.SObjectField> getSObjectFieldList() { return new List<Schema.SObjectField>{ ...
NedlaV's user avatar
  • 86
0 votes
1 answer
335 views

Issue getting object API name from relationship field using Schema

In my project we are using fflib_QueryFactory to build queries and also order fields. Example is given below: fflib_QueryFactory qf = new fflib_QueryFactory(Account.SObjectType) ....
Jason Rickert's user avatar
0 votes
1 answer
182 views

FFLIB Framework Can The Context Be Set To Run As a Specific User?

On an implementation I'm currently working on we have the FFLIB Framework in place. I noted for a requirement to delete specific records that the Framework is enforing triggers to run in context of ...
RedQueries's user avatar
0 votes
1 answer
363 views

unitOfWork (fflib_ISObjectUnitOfWork) clear cache after commitWork()

I have a business process where the Opportunity and Account insertions have to be done in different uow.commitWork() because this use case is using person accounts, and for whatever reason out of my ...
lopez.regalado.fj's user avatar
0 votes
1 answer
51 views

Profile.Name accesability linked to 'View setup and configuration' System Permission

Apparently, getDescribe() is returning isAccessible=false for the field Profile.Name (User object) if the System Permission 'View setup and configuration' is disabled. tokenDescribeSchema....
lopez.regalado.fj's user avatar
1 vote
1 answer
528 views

Mocking Relationship Over Multiple Levels With Apex Mocks

I am trying to bring more mocking into our test class. Many of our queries follow the pattern of user.contact__r.patient__c I am struggling to figure out how to mock this using Apex Mocks. I have not ...
Brooks Johnson's user avatar
1 vote
1 answer
764 views

FFLIB Unit of work (fflib_ISObjectUnitOfWork) and a self-relationship field

I can't get FFLIB uow to work with a self-relationship field. Quick use case: Create two accounts and relate the second one with the first one using a custom lookup field (selfRelation__c) ...
lopez.regalado.fj's user avatar
0 votes
1 answer
646 views

Can I mock out lookup relationship using FFLIB ApexMocks

I'm trying to mock out something similar to the following structure: Task.LastModifiedBy.Username; Task.LookupRelationshipToUser__r.Username; Using the makeRelationships method for this doesn't make ...
saclark12000's user avatar
1 vote
1 answer
232 views

fflib Selector issues with System.runAs()

Looking at bringing in a selector pattern to help reduce a lot of cumbersome test code. But as I refactored, I noticed that after introducing a selector class, the existing test will fail when it uses ...
Brooks Johnson's user avatar
-2 votes
2 answers
1k views

what is the role and meaning of "=>" operator (it's called maps to) in apex enterprise pattern application class ? Please explain [duplicate]

@namespaceAccessible public static final fflib_Application.ServiceFactory service = new fflib_Application.ServiceFactory(new Map<Type, Type> { IHospitalService.class => ...
Sagar's user avatar
  • 35
0 votes
1 answer
239 views

how to get Profile name of lastModifiedBy in fflib selector class

I'm facing issue that when I add LastModifiedBy profile name is getting in soql but when query it in fflib then is getting empty list public List<Order> selectOrderIdsByProfileName(Set<Id> ...
Vinitha vino's user avatar
2 votes
1 answer
666 views

Lean, fast and flexible replacement for the fflib QueryFactory

I just decided to kick the fflib QueryFactory out of a customer project because of its complexity and sub-par performance. My Custom Query Building is fast but I fear I will reinvent the wheel. Which ...
Robert Sösemann's user avatar
2 votes
2 answers
331 views

ApexMocks and UoW implementing IDoWork interface

I have extended the main functionality of the fflib_ISObjectUnitOfWork to enable upserts considering External Ids. Basically, I have created a new class implementing the fflib_SObjectUnitOfWork....
lopez.regalado.fj's user avatar
0 votes
1 answer
642 views

How to add ALL ROWS in fflib selector class

I need to get delete records in SOQL query so i have used ALL ROWS in the end of the SOQL in SOQL its working fine but I need to add in fflib selector class Im getting error public List<...
Vinitha vino's user avatar
1 vote
1 answer
163 views

How to verify non-deterministic field values in a unit test that does no DML?

for fflib / apexmocks users Let's say you have a class/method that inserts new objects where a field value is non-deterministic, say, a UUID public class AccountsServiceImpl { public void ...
cropredy's user avatar
  • 72.5k
0 votes
1 answer
236 views

BASHFUL error running testmethod using ApexMocks (StubApi)

Given fflib code that looks like for (Contact c: contacts) { uow.registerEmail(someEmailMessage); } With testmethod ApexMocks verify (which uses StubApi) ((fflib_SObjectUnitOfWork)mocks.verify(...
cropredy's user avatar
  • 72.5k
2 votes
2 answers
1k views

How to disable CRUD/FLS check from fflib domain layer for only some specific flows. By default it is enabled for all flows using base class

1- I am using fflib for my managed package. 2- By default CRUD/FLS are enabled for all domain/selector flows (Using Base class) 3- In a specific method which is used by site guest users, I want to ...
Customer Foster's user avatar
0 votes
2 answers
227 views

Mocking BusinessHours records returns System.MathException: null

I am stuck on a test method and any help would be highly appreciated. To provide some context: I created a method that queries a specific BusinessHours record on the DB and validates if a Case was ...
user1067017's user avatar
  • 1,024
13 votes
2 answers
960 views

fflib as Second Generation Managed Package (2GP)

So, in a project of mine (a Second Generation Managed Package) I have a dependency on fflib. My initial idea was to include fflib-apex-common and fflib-apex-mocks as 2GPs with the same namespace as my ...
lightxx's user avatar
  • 271
-2 votes
2 answers
482 views

Apex Mock Domain Factory Error

Running into an issue with Implementing Apex Mocking. Everything works fine until I try to set the domain mock in the domain class. Here is My Code: @IsTest private static void testMocking(){ ...
John Pfleger's user avatar
2 votes
1 answer
905 views

Any option for mocking custom metadata records using fflib-ApexMocks and fflib-apex-common?

Given a project based on fflib-apex-common and using fflib-ApexMocks for unit testing, I would like to mock Custom Metadata records and stop using real org values. Custom metadata queries are ...
lopez.regalado.fj's user avatar
1 vote
1 answer
1k views

Apex Mocks avoiding insert when committing fflib Unit of Work

I'm new in Apex Mocks but I'm really excited about all it's advantages. I'm trying to build test without DML. Here is a method I'm trying to test at the moment: public Id createMmDocument(String ...
Miłosz's user avatar
  • 25
0 votes
1 answer
1k views

Testing service methods which fflib unit of work in method's signature

So what I'm tying to do is to unit test one of methods in my service: @TestVisible private void insertSerialNumbers(List<AST_Material_Document_Item__c> documentItems, Map<Id, Asset> ...
Miłosz's user avatar
  • 25
0 votes
3 answers
327 views

fflib Tests fail with required fields on Account

I was looking to find out what approach to take with the fflib libraries and testing. I have added the fflib common and mocks files to my project and org. When I run the tests for the whole project I ...
Peter Caitens's user avatar
7 votes
2 answers
2k views

FFLib Selectors with SOQL For Loops

I'm considering implementation of FFLib, or at least parts of it, throughout our enterprise. Right now I'm focusing on the Selector and Query classes to consolidate our SOQL into a Selector Layer. I'm ...
Morgan Marchese's user avatar
0 votes
1 answer
433 views

Questions regarding implementing fflib_SObjectSelector

As I understand it a selector would be implemented for each SObject that you need it for i.e AccountSelector extends fflib_SObjectSelector {} ServiceAppointmentSelector extendes fflib_SObjectSelector ...
Chris C's user avatar
  • 271
1 vote
1 answer
742 views

Apex Mocks test error for Domain class

We have been using FFLIB(Apex commons) in our org.I have been trying to write a test case for a Content Document Link (Salesforce Files)Domain layer But i have been getting the error : "System....
Pseudodarwinist's user avatar
1 vote
1 answer
201 views

fflib service layer naming convention

I read an article about the service layer here. The names for the services are OpportunitiesService.cls or AccountsService.cls. Does the names of the services always follow the pattern {plural Sobject}...
Cuban coffee's user avatar
  • 1,606
2 votes
1 answer
639 views

not possible to register an object id with an object of the same type

I am registering two new accounts using the fflib unit of work. The code as follows: fflib_ISObjectUnitOfWork uow = Application.unitOfWork.newInstance(); Account account1 = new Account(Name = '...
Cuban coffee's user avatar
  • 1,606
0 votes
1 answer
617 views

Register relationship with FFLIB unit of work

I have been trying to store a big payload as Files and link it to the object EVENT_LOG__c.In the Service layer we have few methods that are called for different events. public void processEvent(String ...
Pseudodarwinist's user avatar
0 votes
1 answer
225 views

Storing JSON payload as Files based on unit of work pattern

I have been trying to store a huge JSON Payload(received as a response from external Integration) as a salesforce File and attach it to the Object's(called as EventLog) record.But my org is based on ...
Pseudodarwinist's user avatar
2 votes
0 answers
207 views

Enterprise Pattern : AccountsSelector: @Override specified for non-overriding method: List<Schema.SObjectField> sptSObjectFieldList()

We have AccountsSelector class extending ApplicationSObjectSelector abstract class from at4dx library. ApplicationSObjectSelector class has public virtual method getSObjectFieldList() I have ...
Sonali takke's user avatar
3 votes
2 answers
2k views

Support of database class methods with fflib UnitOfWork

I am getting a JSON response with multiple account records which I have to upsert in Account object. I am trying to implement this requirement using UOW provided by the fflib library. Is there a way ...
nica's user avatar
  • 1,430
0 votes
1 answer
1k views

Why does the FFLIB framework enforce CRUD security and sharing rules by default for Domains?

In FFLIB, a Domain enforces CRUD security and sharing rules by default. We use FFLIB Domains for implementing triggers. In the Salesforce standard, triggers run in system context, meaning they don't ...
Daniel Wutz's user avatar
9 votes
3 answers
3k views

Mocking Database.QueryLocator in Unit Tests using fflib Apex Mocks

Assume we have some basic AccountSelector class that has different implementations of the selector method. QueryLocator variation is helpful once we need to take advantage of SOQL for loops or to use ...
Oleh Berehovskyi's user avatar
1 vote
1 answer
912 views

SOQL aggregate statement using FFLIB

Please, It is possible to write a SOQL aggregate statement using fflib_SObjectSelector? For example, I have this SOQL request: SELECT DX_Support__r.Name support, SUM(total__c) total FROM ...
FOCOMI's user avatar
  • 15
0 votes
1 answer
811 views

System.QueryException: No such column 'CurrencyIsoCode' on entity 'OpportunityContactRole' while using fflib library

I am using fflib library and querying OpportunityContactRole object in trigger. But its throwing below error -> Opportunity_Trigger: execution of BeforeUpdate caused by: System.QueryException: No ...
arun parmar's user avatar
1 vote
2 answers
146 views

fflib and Knowledge__kav

does anyone use ffLib with Knowledge__kav? I am facing weird issue when using those. When user without knowledge access fire logic and go trough centralized class that stores references to all ...
Artur Kępczyński's user avatar