Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions sfdx-source/apex-common/main/classes/fflib_QueryFactory.cls
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr
public Schema.SObjectType table {get; private set;}
@TestVisible
private Set<String> fields;
private Set<String> setFieldsByLabel;
private String conditionExpression;
private Integer limitCount;
private Integer offsetCount;
Expand Down Expand Up @@ -364,6 +365,13 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr
this.conditionExpression = conditionExpression;
return this;
}
/**
* @param setFieldsByLabel set the picklist fields to return the value by picklist Label.
**/
public fflib_QueryFactory setPicklistFieldsByLabel(Set<String> setFieldsByLabel){
this.setFieldsByLabel = setFieldsByLabel;
return this;
}
/**
* @returns the current value of the WHERE clause, if any, as set by {@link #setCondition}
**/
Expand Down Expand Up @@ -727,6 +735,14 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr
}

result += String.join(fieldsToQuery,', ');
if(setFieldsByLabel != null && !setFieldsByLabel.isEmpty() ){
for(String strField : fieldsToQuery){
if(setFieldsByLabel.contains(strField))
{
result = result.replace(strField, 'toLabel('+strField+')');
}
}
}
}

if(subselectQueryMap != null && !subselectQueryMap.isEmpty()){
Expand Down Expand Up @@ -778,6 +794,7 @@ public class fflib_QueryFactory { //No explicit sharing declaration - inherit fr
.setLimit(this.limitCount)
.setOffset(this.offsetCount)
.setCondition(this.conditionExpression)
.setPicklistFieldsByLabel(this.setFieldsByLabel)
.setEnforceFLS(this.mFlsEnforcement);

Map<Schema.ChildRelationship, fflib_QueryFactory> subqueries = this.subselectQueryMap;
Expand Down