import simple_salesforce
from cumulusci.tasks.salesforce import BaseSalesforceApiTask

class is_rd2_enabled(BaseSalesforceApiTask):
    def _run_task(self):
        try:
            settings = self.sf.query(
                "SELECT IsRecurringDonations2Enabled__c "
                "FROM npe03__Recurring_Donations_Settings__c "
                "WHERE SetupOwnerId IN (SELECT Id FROM Organization)"
            )
        except simple_salesforce.exceptions.SalesforceMalformedRequest:
            # The field does not exist in the target org, meaning it's
            # pre-RD2
            self.return_values = False
            return

        if settings.get("records"):
            if settings["records"][0]["IsRecurringDonations2Enabled__c"]:
                self.return_values = True

        self.return_values = False
import simple_salesforce
from cumulusci.tasks.salesforce import BaseSalesforceApiTask

class is_rd2_enabled(BaseSalesforceApiTask):
    def _run_task(self):
        try:
            settings = self.sf.query(
                "SELECT IsRecurringDonations2Enabled__c "
                "FROM npe03__Recurring_Donations_Settings__c "
                "WHERE SetupOwnerId IN (SELECT Id FROM Organization)"
            )
        except simple_salesforce.exceptions.SalesforceMalformedRequest:
            # The field does not exist in the target org, meaning it's
            # pre-RD2
            self.return_values = False
            return

        if settings.get("records"):
            if settings["records"][0]["IsRecurringDonations2Enabled__c"]:
                self.return_values = True
                return

        self.return_values = False
Correct bug in preflight check
Correct bug in preflight check

  import simple_salesforce
  from cumulusci.tasks.salesforce import BaseSalesforceApiTask
  
  class is_rd2_enabled(BaseSalesforceApiTask):
      def _run_task(self):
          try:
              settings = self.sf.query(
                  "SELECT IsRecurringDonations2Enabled__c "
                  "FROM npe03__Recurring_Donations_Settings__c "
                  "WHERE SetupOwnerId IN (SELECT Id FROM Organization)"
              )
          except simple_salesforce.exceptions.SalesforceMalformedRequest:
              # The field does not exist in the target org, meaning it's
              # pre-RD2
              self.return_values = False
              return
  
          if settings.get("records"):
              if settings["records"][0]["IsRecurringDonations2Enabled__c"]:
                  self.return_values = True
+                 return
  
          self.return_values = False
Correct bug in preflight check
## Code Before:
import simple_salesforce
from cumulusci.tasks.salesforce import BaseSalesforceApiTask

class is_rd2_enabled(BaseSalesforceApiTask):
    def _run_task(self):
        try:
            settings = self.sf.query(
                "SELECT IsRecurringDonations2Enabled__c "
                "FROM npe03__Recurring_Donations_Settings__c "
                "WHERE SetupOwnerId IN (SELECT Id FROM Organization)"
            )
        except simple_salesforce.exceptions.SalesforceMalformedRequest:
            # The field does not exist in the target org, meaning it's
            # pre-RD2
            self.return_values = False
            return

        if settings.get("records"):
            if settings["records"][0]["IsRecurringDonations2Enabled__c"]:
                self.return_values = True

        self.return_values = False
## Instruction:
Correct bug in preflight check
## Code After:
import simple_salesforce
from cumulusci.tasks.salesforce import BaseSalesforceApiTask

class is_rd2_enabled(BaseSalesforceApiTask):
    def _run_task(self):
        try:
            settings = self.sf.query(
                "SELECT IsRecurringDonations2Enabled__c "
                "FROM npe03__Recurring_Donations_Settings__c "
                "WHERE SetupOwnerId IN (SELECT Id FROM Organization)"
            )
        except simple_salesforce.exceptions.SalesforceMalformedRequest:
            # The field does not exist in the target org, meaning it's
            # pre-RD2
            self.return_values = False
            return

        if settings.get("records"):
            if settings["records"][0]["IsRecurringDonations2Enabled__c"]:
                self.return_values = True
                return

        self.return_values = False