Answers.Body: <p>Did you recently merge Organization contact which was related to membership type? If yes than its a known error in CiviCRM. I always prefer to retain the contact linked to membership type or settings. Or another option to avoid this in future we have installed an <a href="https://github.com/pradpnayak/mergecontactfixes" rel="nofollow noreferrer">extension</a> on most of our client site.</p>
  <p>Solution to fix the problem? Run below query to fix the price set data.</p>
  <pre><code>SELECT cpf.id, cpf.name, cmt.member_of_contact_id,  cpfv.membership_type_id
  FROM civicrm_price_field cpf 
    INNER JOIN civicrm_price_field_value cpfv 
      ON cpfv.price_field_id = cpf.id 
    INNER JOIN civicrm_price_set cps 
      ON cps.id = cpf.price_set_id AND cps.name = 'default_membership_type_amount'
    INNER JOIN civicrm_membership_type cmt
      ON cmt.id = cpfv.membership_type_id;
  </code></pre>
  <p>-- Incase above query returned results with cpf.name &lt;&gt; cmt.member_of_contact_id than run below query.</p>
  <pre><code>UPDATE civicrm_price_field cpf 
    INNER JOIN civicrm_price_field_value cpfv 
      ON cpfv.price_field_id = cpf.id 
    INNER JOIN civicrm_price_set cps 
      ON cps.id = cpf.price_set_id AND cps.name = 'default_membership_type_amount'
    INNER JOIN civicrm_membership_type cmt
      ON cmt.id = cpfv.membership_type_id
  SET cpf.name = cmt.member_of_contact_id;
  </code></pre>
  <p>HTH</p>
  <p>Pradeep</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-24T08:12:56.873Z
Answers.Text: Thank you @pradeep, yes we did bulk merge last week. Most of the things you mentioned is over my head, will try to run the mysql command and get back to you soon.
Answers.UserDisplayName: FullStack-Dev
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-24T19:29:26.030Z
Answers.Text: The update sql query fixed the problem, thanks again
Answers.UserDisplayName: FullStack-Dev
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-23T21:10:52.807Z
Answers.LastActivityDate: 2021-05-23T21:10:52.807Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>Our system has 26 different membership type, for 3 different member organization. Since 5.35 Civi upgrade sometimes we are unable to create/update membership from New/Edit backend membership form. We encountered following errors(without priceset)</p>
  <ol>
  <li>Please select a membership type (even though membership type is selected).</li>
  <li>Unable to add membership for the contact.</li>
  <li>Membership field is not updated(like source, join date, custom fields etc) but status message says saved successfully.</li>
  <li>Upon submitting new membership says saved successfully but no membership is created.</li>
  </ol>
  <p>There are so many scenarios where it fails to create and update membership. However it does work i.e save/update sometimes for some membership types but not for all.</p>
  <p>Couldn't replicate the error on dmaster.demo.civicrm.org, may be because we are on older version of Civi? Is this already fixed in latest version of Civi, if so how difficult is it to port the changes to 5.35.2(we don't want to update Civi unless we do thorough testing)?</p>
  <p>Any pointers or help really appreciated.</p>
  <p>Thanks in advance</p>
  <p>Abhi</p>
  
Tags: <civimember>
Title: Unable to create membership
ThreadText: # Unable to create membership
  
  (Asked by: username_0 on 2021-05-22)
  
  Our system has 26 different membership type, for 3 different member organization. Since 5.35 Civi upgrade sometimes we are unable to create/update membership from New/Edit backend membership form. We encountered following errors(without priceset)
  
  1. Please select a membership type (even though membership type is selected).
  2. Unable to add membership for the contact.
  3. Membership field is not updated(like source, join date, custom fields etc) but status message says saved successfully.
  4. Upon submitting new membership says saved successfully but no membership is created.
  
  There are so many scenarios where it fails to create and update membership. However it does work i.e save/update sometimes for some membership types but not for all.
  
  Couldn't replicate the error on dmaster.demo.civicrm.org, may be because we are on older version of Civi? Is this already fixed in latest version of Civi, if so how difficult is it to port the changes to 5.35.2(we don't want to update Civi unless we do thorough testing)?
  
  Any pointers or help really appreciated.
  
  Thanks in advance
  
  Abhi
  
  **Tags:** civimember
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-05-23. Score: 2
  
  Did you recently merge Organization contact which was related to membership type? If yes than its a known error in CiviCRM. I always prefer to retain the contact linked to membership type or settings. Or another option to avoid this in future we have installed an [extension](https://github.com/pradpnayak/mergecontactfixes) on most of our client site.
  
  Solution to fix the problem? Run below query to fix the price set data.
  
  ```
  SELECT cpf.id, cpf.name, cmt.member_of_contact_id,  cpfv.membership_type_id
  FROM civicrm_price_field cpf 
    INNER JOIN civicrm_price_field_value cpfv 
      ON cpfv.price_field_id = cpf.id 
    INNER JOIN civicrm_price_set cps 
      ON cps.id = cpf.price_set_id AND cps.name = 'default_membership_type_amount'
    INNER JOIN civicrm_membership_type cmt
      ON cmt.id = cpfv.membership_type_id;
  
  ```
  
  -- Incase above query returned results with cpf.name <> cmt.member\_of\_contact\_id than run below query.
  
  ```
  UPDATE civicrm_price_field cpf 
    INNER JOIN civicrm_price_field_value cpfv 
      ON cpfv.price_field_id = cpf.id 
    INNER JOIN civicrm_price_set cps 
      ON cps.id = cpf.price_set_id AND cps.name = 'default_membership_type_amount'
    INNER JOIN civicrm_membership_type cmt
      ON cmt.id = cpfv.membership_type_id
  SET cpf.name = cmt.member_of_contact_id;
  
  ```
  
  HTH
  
  username_1
  
  > **Comments:**
  > **username_0**: Thank you @username_1, yes we did bulk merge last week. Most of the things you mentioned is over my head, will try to run the mysql command and get back to you soon.  
  > **username_0**: The update sql query fixed the problem, thanks again  
  
  ---
  
  