@@ -178,6 +178,8 @@ class SalesforceSourceReport(StaleEntityRemovalSourceReport):
178
178
default_factory = LossyList
179
179
)
180
180
181
+ num_objects_missing_formula : int = 0
182
+
181
183
def report_dropped (self , ent_name : str ) -> None :
182
184
self .filtered .append (ent_name )
183
185
@@ -636,8 +638,14 @@ def get_salesforce_object_workunits(
636
638
# Although formula is present in Metadata column of CustomField entity,
637
639
# we can not use it as it allows querying only for one field at a time
638
640
# and that would not be performant
639
- self .report .objects_with_calculated_field .append (sObjectName )
640
641
calculated_field_formulae = self .get_calculated_field_formulae (sObjectName )
642
+ if calculated_field_formulae :
643
+ self .report .objects_with_calculated_field .append (sObjectName )
644
+ else :
645
+ # For some objects, although some fields are calculated, formula is absent
646
+ # These are typically salesforce system calculated fields whose formula
647
+ # is not exposed
648
+ self .report .num_objects_missing_formula += 1
641
649
else :
642
650
calculated_field_formulae = {}
643
651
@@ -851,26 +859,27 @@ def _get_field_description(
851
859
customField : Optional [CustomField ],
852
860
formula : Optional [str ],
853
861
) -> str :
854
- if "Label" not in field or field [ "Label" ] is None :
855
- desc = ""
856
- elif field ["Label" ].startswith ("#" ):
857
- desc = "\\ " + field ["Label" ]
858
- else :
859
- desc = field ["Label" ]
862
+ description_parts : List [ str ] = []
863
+
864
+ if field . get ( "Label" ) and field ["Label" ].startswith ("#" ):
865
+ description_parts . append ( "\\ " + field ["Label" ])
866
+ elif field . get ( "Label" ) :
867
+ description_parts . append ( field ["Label" ])
860
868
861
869
text = field .get ("FieldDefinition" , {}).get ("Description" , None )
862
870
if text :
863
871
prefix = "\\ " if text .startswith ("#" ) else ""
864
- desc += f" \n \n { prefix } { text } "
872
+ description_parts . append ( f" { prefix } { text } ")
865
873
866
874
text = field .get ("InlineHelpText" )
867
875
if text :
868
876
prefix = "\\ " if text .startswith ("#" ) else ""
869
- desc += f" \n \n { prefix } { text } "
877
+ description_parts . append ( f" { prefix } { text } ")
870
878
871
879
if formula :
872
- desc += f"\n \n Formula: { formula } "
873
- return desc
880
+ description_parts .append (f"Formula: { formula } " )
881
+
882
+ return "\n \n " .join (description_parts )
874
883
875
884
# Here jsonProps is used to add additional salesforce field level properties.
876
885
def _get_field_json_props (
@@ -881,6 +890,9 @@ def _get_field_json_props(
881
890
if field .get ("IsUnique" ):
882
891
jsonProps ["IsUnique" ] = True
883
892
893
+ if field .get ("IsCalculated" ):
894
+ jsonProps ["IsCalculated" ] = True
895
+
884
896
return json .dumps (jsonProps )
885
897
886
898
def _get_schema_field (
0 commit comments