API_Exception: Unknown api parameter: setRelationship

Created on 24 January 2023, almost 2 years ago
Updated 1 February 2023, almost 2 years ago

After updating the webform_civicrm module to 6.2.2 we began getting errors for forms with CiviCRM relationships. I am not sure whether this is unique to our installation or if it is a common issue. It did not exist with 6.2.1, and rolling back to 6.2.1 resolves our immediate problem.

The specific error we're seeing in the log is:
API_Exception: Unknown api parameter: setRelationship in Civi\Api4\Generic\AbstractAction->__call() (line 218 of /var/www/html/vendor/civicrm/civicrm-core/Civi/Api4/Generic/AbstractAction.php).

The form page is a wsod, but removing this line from the yaml '#default': relationship allows the page to load - not really sure why - but when submitting the form the same API_Exception occurs.

🐛 Bug report
Status

Fixed

Version

6.2

Component

CiviCRM Data Handling

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jstephens.hshsl
  • 🇨🇦Canada karing 🇨🇦

    Can you please post what you see in the source tab (under Build)? Then we can try to reproduce it and fix it.

  • 🇨🇦Canada karing 🇨🇦

    Can you please post what you see in the source tab (under Build)? Then we can try to reproduce it and fix it.

  • The whole thing is about 1300 lines! I can post it all if it is helpful, but the stanza that seems to be related is:

    ivicrm_2_contact_1_contact_existing:
        '#type': civicrm_contact
        '#title': 'Lead Organization'
        '#widget': select
        '#search_prompt': '- Choose existing -'
        '#none_prompt': '+ Create new +'
        '#results_display':
          display_name: display_name
        '#default': relationship
        '#default_relationship_to': '1'
        '#default_relationship':
          5_b: 5_b
        '#allow_url_autofill': false
        '#filter_relationship_contact': '1'
        '#filter_relationship_types':
          5_b: 5_b
        '#check_permissions': 0
        '#allow_create': 1
        '#contact_type': organization
        '#form_key': civicrm_2_contact_1_contact_existing
        '#parent': civicrm_2_contact_1_fieldset_fieldset
        '#extra': {  }
  • The whole thing is around 1300, lines. If it is helpful I can send it, but this section seems the most applicable:

    Civicrm_2_contact_1_contact_existing:
        '#type': civicrm_contact
        '#title': 'Lead Organization'
        '#widget': select
        '#search_prompt': '- Choose existing -'
        '#none_prompt': '+ Create new +'
        '#results_display':
          display_name: display_name
        '#default': relationship
        '#default_relationship_to': '1'
        '#default_relationship':
          5_b: 5_b
        '#allow_url_autofill': false
        '#filter_relationship_contact': '1'
        '#filter_relationship_types':
          5_b: 5_b
        '#check_permissions': 0
        '#allow_create': 1
        '#contact_type': organization
        '#form_key': civicrm_2_contact_1_contact_existing
        '#parent': civicrm_2_contact_1_fieldset_fieldset
        '#extra': {  }
  • I've tried to post a few times and it doesn't seem to be going. Not sure why!

  • 🇨🇦Canada karing 🇨🇦

    Can you please create the smallest form possible and using core relationships -> that shows the issue. Then:

    • export that webform (Extend -> enable Configuration Manager
    • Configuration -> Configuration synchronization -> Export -> Single Item -> select your webform
    • Copy/paste that YAML here for us

    This will allow us to import it on one of our dev sites.

  • Walking through the form, I found that it didn't break until I got down to the settings for contact 2 around line 291:

    uuid: 0da29377-fcfb-47a1-a9b3-2a83001163d0
    langcode: en
    status: open
    dependencies:
      module:
        - webform_civicrm
    weight: 0
    open: null
    close: null
    uid: 25401
    template: false
    archive: false
    id: test_form
    title: 'Test Form'
    description: ''
    category: ''
    elements: |-
      markup_04:
        '#type': webform_markup
        '#markup': '<h2>Grant Application</h2>'
      civicrm_1_contact_1_fieldset_fieldset:
        '#type': fieldset
        '#title': 'Your Information'
        '#description': '...'
        '#form_key': civicrm_1_contact_1_fieldset_fieldset
        civicrm_1_contact_1_contact_existing:
          '#type': civicrm_contact
          '#search_prompt': '- Choose existing -'
          '#widget': hidden
          '#form_key': civicrm_1_contact_1_contact_existing
          '#allow_create': 1
          '#none_prompt': '+ Create new +'
          '#default': user
          '#contact_type': individual
          '#parent': civicrm_1_contact_1_fieldset_fieldset
          '#extra': {  }
          '#title': 'Existing Contact'
        civicrm_1_contact_1_contact_first_name:
          '#type': textfield
          '#contact_type': individual
          '#form_key': civicrm_1_contact_1_contact_first_name
          '#extra':
            width: 20
          '#parent': civicrm_1_contact_1_fieldset_fieldset
          '#title': 'First Name'
      civicrm_2_contact_1_fieldset_fieldset:
        '#type': fieldset
        '#title': 'Lead Organization'
        '#description': '...'
        '#description_display': before
        '#form_key': civicrm_2_contact_1_fieldset_fieldset
        civicrm_2_contact_1_contact_existing:
          '#type': civicrm_contact
          '#title': 'Lead Organization'
          '#widget': select
          '#search_prompt': '- Choose existing -'
          '#none_prompt': '+ Create new +'
          '#results_display':
            display_name: display_name
          '#default': relationship
          '#default_relationship_to': '1'
          '#default_relationship':
            5_b: 5_b
          '#allow_url_autofill': false
          '#filter_relationship_contact': '1'
          '#filter_relationship_types':
            5_b: 5_b
          '#check_permissions': 0
          '#allow_create': 1
          '#contact_type': organization
          '#form_key': civicrm_2_contact_1_contact_existing
          '#parent': civicrm_2_contact_1_fieldset_fieldset
          '#extra': {  }
        civicrm_2_contact_1_contact_organization_name:
          '#type': textfield
          '#contact_type': organization
          '#form_key': civicrm_2_contact_1_contact_organization_name
          '#extra':
            width: 20
          '#parent': civicrm_2_contact_1_fieldset_fieldset
          '#title': 'Organization Name'
    css: ''
    javascript: ''
    settings:
      ajax: false
      ajax_scroll_top: form
      ajax_progress_type: ''
      ajax_effect: ''
      ajax_speed: null
      page: true
      page_submit_path: ''
      page_confirm_path: ''
      page_theme_name: ''
      form_title: both
      form_submit_once: false
      form_open_message: ''
      form_close_message: ''
      form_exception_message: ''
      form_previous_submissions: true
      form_confidential: false
      form_confidential_message: ''
      form_disable_remote_addr: false
      form_convert_anonymous: false
      form_prepopulate: false
      form_prepopulate_source_entity: false
      form_prepopulate_source_entity_required: false
      form_prepopulate_source_entity_type: ''
      form_unsaved: false
      form_disable_back: false
      form_submit_back: false
      form_disable_autocomplete: false
      form_novalidate: false
      form_disable_inline_errors: false
      form_required: false
      form_autofocus: false
      form_details_toggle: false
      form_reset: false
      form_access_denied: default
      form_access_denied_title: ''
      form_access_denied_message: ''
      form_access_denied_attributes: {  }
      form_file_limit: ''
      form_attributes: {  }
      form_method: ''
      form_action: ''
      share: false
      share_node: false
      share_theme_name: ''
      share_title: true
      share_page_body_attributes: {  }
      submission_label: ''
      submission_exception_message: ''
      submission_locked_message: ''
      submission_log: false
      submission_excluded_elements: {  }
      submission_exclude_empty: false
      submission_exclude_empty_checkbox: false
      submission_views: {  }
      submission_views_replace: {  }
      submission_user_columns: {  }
      submission_user_duplicate: false
      submission_access_denied: default
      submission_access_denied_title: ''
      submission_access_denied_message: ''
      submission_access_denied_attributes: {  }
      previous_submission_message: ''
      previous_submissions_message: ''
      autofill: false
      autofill_message: ''
      autofill_excluded_elements: {  }
      wizard_progress_bar: true
      wizard_progress_pages: false
      wizard_progress_percentage: false
      wizard_progress_link: false
      wizard_progress_states: false
      wizard_start_label: ''
      wizard_preview_link: false
      wizard_confirmation: true
      wizard_confirmation_label: ''
      wizard_auto_forward: true
      wizard_auto_forward_hide_next_button: false
      wizard_keyboard: true
      wizard_track: ''
      wizard_prev_button_label: ''
      wizard_next_button_label: ''
      wizard_toggle: false
      wizard_toggle_show_label: ''
      wizard_toggle_hide_label: ''
      preview: 0
      preview_label: ''
      preview_title: ''
      preview_message: ''
      preview_attributes: {  }
      preview_excluded_elements: {  }
      preview_exclude_empty: true
      preview_exclude_empty_checkbox: false
      draft: none
      draft_multiple: false
      draft_auto_save: false
      draft_saved_message: ''
      draft_loaded_message: ''
      draft_pending_single_message: ''
      draft_pending_multiple_message: ''
      confirmation_type: page
      confirmation_url: ''
      confirmation_title: ''
      confirmation_message: ''
      confirmation_attributes: {  }
      confirmation_back: true
      confirmation_back_label: ''
      confirmation_back_attributes: {  }
      confirmation_exclude_query: false
      confirmation_exclude_token: false
      confirmation_update: false
      limit_total: null
      limit_total_interval: null
      limit_total_message: ''
      limit_total_unique: false
      limit_user: null
      limit_user_interval: null
      limit_user_message: ''
      limit_user_unique: false
      entity_limit_total: null
      entity_limit_total_interval: null
      entity_limit_user: null
      entity_limit_user_interval: null
      purge: none
      purge_days: null
      results_disabled: false
      results_disabled_ignore: false
      results_customize: false
      token_view: false
      token_update: false
      token_delete: false
      serial_disabled: false
    access:
      create:
        roles:
          - anonymous
          - authenticated
        users: {  }
        permissions: {  }
      view_any:
        roles: {  }
        users: {  }
        permissions: {  }
      update_any:
        roles: {  }
        users: {  }
        permissions: {  }
      delete_any:
        roles: {  }
        users: {  }
        permissions: {  }
      purge_any:
        roles: {  }
        users: {  }
        permissions: {  }
      view_own:
        roles: {  }
        users: {  }
        permissions: {  }
      update_own:
        roles: {  }
        users: {  }
        permissions: {  }
      delete_own:
        roles: {  }
        users: {  }
        permissions: {  }
      administer:
        roles: {  }
        users: {  }
        permissions: {  }
      test:
        roles: {  }
        users: {  }
        permissions: {  }
      configuration:
        roles: {  }
        users: {  }
        permissions: {  }
    handlers:
      civicrm:
        id: webform_civicrm
        handler_id: civicrm
        label: CiviCRM
        notes: ''
        status: true
        conditions: {  }
        weight: 0
        settings:
          data:
            contact:
              1:
                contact:
                  1:
                    contact_type: individual
                    contact_sub_type: {  }
                    webform_label: 'Contact 1'
                matching_rule: Unsupervised
                number_of_cg2: '0'
                number_of_cg23: '0'
                number_of_other: '0'
                number_of_address: '0'
                number_of_phone: '0'
                number_of_email: '0'
                number_of_website: '0'
                number_of_im: '0'
                number_of_cg3: '0'
              2:
                contact:
                  1:
                    contact_type: organization
                    contact_sub_type: {  }
                    webform_label: 'Lead Organization'
                matching_rule: Unsupervised
                number_of_cg5: '0'
                number_of_other: '0'
                number_of_address: '0'
                number_of_phone: '0'
                number_of_email: '0'
                number_of_website: '0'
                number_of_im: '0'
                number_of_relationship: '0'
                number_of_cg3: '0'
            reg_options:
              validate: 1
          confirm_subscription: 1
          create_fieldsets: 1
          new_contact_source: ''
          civicrm_1_contact_1_contact_first_name: create_civicrm_webform_element
          civicrm_1_contact_1_contact_last_name: create_civicrm_webform_element
          civicrm_1_contact_1_contact_existing: create_civicrm_webform_element
    variants: {  }
    
  • Assigned to jitendrapurohit
  • Status changed to Needs review almost 2 years ago
  • 🇮🇳India jitendrapurohit

    I've raised a PR with the fix - https://github.com/colemanw/webform_civicrm/pull/835. It also includes a test so it does not regress again. @jstephens.hshsl Can you please review so we can merge it?

    Thanks.

  • Issue was unassigned.
  • Status changed to Active almost 2 years ago
  • Hello,

    Yes this change solves the issue. Thank you!

  • Status changed to Fixed almost 2 years ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024