From e16023a4afe7b88c8ce8b63d493a8f2ebd1604e4 Mon Sep 17 00:00:00 2001 From: Christopher Gary Date: Fri, 16 Apr 2021 17:31:01 -0400 Subject: [PATCH] Added Custom Label for Field Exclusing functionality --- .forceignore | 15 +++++++++++++++ .../default/classes/OpportunityCloneService.cls | 9 +++++++++ .../default/labels/CustomLabels.labels-meta.xml | 10 +++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/.forceignore b/.forceignore index 2e8ef3e..b923931 100644 --- a/.forceignore +++ b/.forceignore @@ -35,5 +35,20 @@ package.xml # Exclude Custom Fields *.field +# Exclude specific objects +OpportunityStageHistory__c.object + +# Exclude specific classes +OppStageService.cls +OppStageServiceTest.cls +OpportunityTriggerHandler.cls +OpportunityTriggerHandlerTest.cls + +# Exclude Specific Triggers +OpportunityTrigger.trigger + +# Exclude Report Types +*.reportType + # Exclude the Opportnity CustomObject Opportunity.object \ No newline at end of file diff --git a/force-app/main/default/classes/OpportunityCloneService.cls b/force-app/main/default/classes/OpportunityCloneService.cls index b59591c..1e191fa 100644 --- a/force-app/main/default/classes/OpportunityCloneService.cls +++ b/force-app/main/default/classes/OpportunityCloneService.cls @@ -85,6 +85,11 @@ public with sharing class OpportunityCloneService { @AuraEnabled public static Id CloneOpportunityWithChildren(Id oppId, Map newValues, List childRelationshipsToClone) { + String oppFieldListToClearString = Label.SmartCloneForceClearFieldList; + List oppFieldListToClear = new List(); + if(!oppFieldListToClearString.contains('N/A')){ + oppFieldListToClear = oppFieldListToClearString.split(';'); + } //dynamic query in order to find the original opportunity. String originalOppQueryString = ObtainQueryStringForOppAndChildren(oppId, childRelationshipsToClone); System.debug(LoggingLevel.INFO,'\n\n*****\nQuery: ' + originalOppQueryString + '\n*****\n\n'); @@ -100,6 +105,10 @@ public with sharing class OpportunityCloneService { for(String fieldName:newValues.keySet()){ clonedOpp.put(fieldName, CreateObjectValueFromString(fieldName,newValues.get(fieldName))); } + //clear out field values listed + for(String fieldName:oppFieldListToClear) { + clonedOpp.put(fieldName,null); + } //insert the new Opportunity try{ insert clonedOpp; diff --git a/force-app/main/default/labels/CustomLabels.labels-meta.xml b/force-app/main/default/labels/CustomLabels.labels-meta.xml index ee2f647..e903cab 100644 --- a/force-app/main/default/labels/CustomLabels.labels-meta.xml +++ b/force-app/main/default/labels/CustomLabels.labels-meta.xml @@ -6,6 +6,14 @@ en_US true SmartClone Child List - OpportunityLineItem + N/A + + + SmartCloneForceClearFieldList + SmartClone Config + en_US + true + SmartCloneForceClearFieldList + N/A