Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setFieldValueByMap to consume a Map<Id, Id> #390

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JAertgeerts
Copy link
Contributor

@JAertgeerts JAertgeerts commented Dec 14, 2021

This change is Reviewable

@ImJohnMDaniel
Copy link
Contributor

@JAertgeerts -- thanks for the PR. A couple of questions:

  • Why is this change needed?
  • Can you provide corresponding code coverage please?

@wimvelzeboer
Copy link
Contributor

@ImJohnMDaniel The purpose of the domain is to allow easy access to the list of objects it contains. There are three primary types of methods on the domain; getters, setters and filter methods.
The more standard setter methods we have in the fflib_SObjects domain class, the smaller the methods can become on the domain classes (e.g. Accounts).

This method allows for easy setting and Id field based on the provided map. An example would be the following method, which sets the Case.OwnerId based on the provided map. It check if the Case.AccountId is populated in the map, if so, then it takes the value of that key and sets it to the provided target field, the Case.OwernId.

public ICases setOwnerIdByAccountId(Map<Id, Id> UserIdByAccountId)
{
   setFieldValueByMap(Case.AccountId, Case.OwnerId, UserIdByAccountId);
   return this;
}

Since Salesforce is a bit limited with casting a Map<Object, Object> to a Map<Id, Id> we need another method overload.

@ImJohnMDaniel
Copy link
Contributor

@JAertgeerts, just following up on the request to provide matching code coverage for this method. Cheers!

Copy link
Contributor

@daveespo daveespo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @ImJohnMDaniel, @JAertgeerts, and @stohn777)


sfdx-source/apex-common/main/classes/fflib_SObjects.cls, line 294 at r1 (raw file):

	 * @param values Map of values to store by the sObjectFieldToCheck fields value
	 */
	protected virtual void setFieldValueByMap(

Agreed with JohnD, we need a test method to cover this new code path

wimvelzeboer added a commit to wimvelzeboer/fflib-apex-common that referenced this pull request Apr 6, 2022
Now it can consume a Map<Id, *> and Map<String, *> and includes unit-test

Replaces PR: apex-enterprise-patterns#390
wimvelzeboer added a commit to wimvelzeboer/fflib-apex-common that referenced this pull request Apr 6, 2022
Now it can consume a Map<Id, *> and Map<String, *> and includes unit-test

Replaces PR: apex-enterprise-patterns#390
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants