Skip to content

Commit

Permalink
Add ID type knowledge to LREngine
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcarter committed Nov 23, 2015
1 parent 4bc42b6 commit 7584ca2
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions rolluptool/src/classes/LREngine.cls
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ public class LREngine {
public boolean isMasterTypeCurrency;
public boolean isMasterTypeText;
public boolean isDetailTypeText;
public boolean isMasterTypeId;
public boolean isDetailTypeId;

public RollupSummaryField(Schema.Describefieldresult m,
Schema.Describefieldresult d, RollupOperation op) {
Expand All @@ -396,6 +398,8 @@ public class LREngine {
this.isMasterTypeCurrency = isCurrency(master.getType());
this.isMasterTypeText = isText(master.getType());
this.isDetailTypeText = isText(detail.getType());
this.isMasterTypeId = isIdOrReference(master.getType());
this.isDetailTypeId = isIdOrReference(detail.getType());
// validate if field is good to work on later
validate();
}
Expand All @@ -414,8 +418,9 @@ public class LREngine {
if (operation == RollupOperation.First ||
operation == RollupOperation.Last) {
if ( (this.master.getType() != this.detail.getType()) &&
(!isDetailTypeText && !isMasterTypeText) ) {
throw new BadRollUpSummaryStateException('Master and detail fields must be the same field type (or text based) for First or Last operations');
((!isDetailTypeText && !isDetailTypeId) ||
(!isMasterTypeText && !isMasterTypeId))) {
throw new BadRollUpSummaryStateException('Master and detail fields must be the same field type (or text/Id based) for First or Last operations');
}
}

Expand All @@ -440,6 +445,11 @@ public class LREngine {
dt == Schema.Displaytype.Picklist ||
dt == Schema.Displaytype.MultiPicklist;
}

boolean isIdOrReference (Schema.Displaytype dt) {
return dt == Schema.DisplayType.ID ||
dt == Schema.DisplayType.REFERENCE;
}

boolean isNumber (Schema.Displaytype dt) {
return dt == Schema.Displaytype.Currency
Expand Down Expand Up @@ -592,4 +602,4 @@ public class LREngine {
}
}

}
}

0 comments on commit 7584ca2

Please sign in to comment.