From 5fdf6367db0296664e057bcd79a9d4fe7a43596c Mon Sep 17 00:00:00 2001 From: Jason Lantz Date: Tue, 28 Apr 2020 18:50:37 -0500 Subject: [PATCH] Don't strip default from all record types --- tasks/update_profile.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tasks/update_profile.py b/tasks/update_profile.py index 2fe0807..e3a6b76 100644 --- a/tasks/update_profile.py +++ b/tasks/update_profile.py @@ -19,4 +19,30 @@ def _expand_package_xml(self, package_xml): custom_objects.append( "members", text=f"{record['NamespacePrefix']}__{record['DeveloperName']}__c", - ) \ No newline at end of file + ) + + def _set_record_types(self, tree, api_name): + record_types = self.options.get("record_types") or [] + + # Set recordTypeVisibilities + for rt in record_types: + # Replace namespace prefix tokens in rt name + rt_prefixed = rt["record_type"].format(**self.namespace_prefixes) + + # Look for the recordTypeVisiblities element + elem = tree.find("recordTypeVisibilities", recordType=rt_prefixed) + if elem is None: + raise TaskOptionsError( + f"Record Type {rt['record_type']} not found in retrieved {api_name}.profile" + ) + + # Set visible + elem.visible.text = str(rt.get("visible", "true")).lower() + + # Set default + elem.default.text = str(rt.get("default", "false")).lower() + + # Set person account default if element exists + pa_default = elem.find("personAccountDefault") + if pa_default is not None: + pa_default.text = str(rt.get("person_account_default", "false")).lower() \ No newline at end of file