Answers.Body: <p>Thinking out loud......</p>
  
  <ul>
  <li>create an extension with perhaps an API that accepts a contact_id as a param and returns the oldest membership start date</li>
  <li>assuming you know in advance what the member since should be you could use the buildForm hook to change the value (using the API or doing the calculation in a a specific class)</li>
  <li>alternatively add a little jQuery (using the CRM_Core_Region, see <a href="https://docs.civicrm.org/dev/en/latest/framework/region/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/framework/region/</a>) to the form that replaces the core value with the "correct" value using the API request?</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-18T07:06:43.027Z
Answers.LastActivityDate: 2019-07-18T07:06:43.027Z
Answers.UserDisplayName: ErikH - CiviCooP
Answers.Body: <p>How immediately do you need this field's value to be set? If it can be delayed, I'd probably do this as a cron script that loops through all that aren't set yet and then sets its value.</p>
  
  <p>I'm assuming also you're familiar with the "View only" checkbox at the bottom of the custom field definition form - that would be how I'd create this field.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-17T23:50:49.570Z
Answers.LastActivityDate: 2019-07-17T23:50:49.570Z
Answers.UserDisplayName: Demerit
Body: <p>I've been thinking about how to best approach this and I'm stumped as to how to best go about it.</p>
  
  <p>I want to add a custom field to a profile that is rendered on the Contact Summary page. I would like to fill it dynamically with the value of the individual's earliest Member Since value. </p>
  
  <p><strong>NOTE:</strong> <em>I say the earliest Member Since value because a bug in Civi has changed all Member Since values of currently active membership records to the date of the start of that membership record when they are renewed which ignores the concept that the individual may have had an earlier membership of a different type. The solution is to loop through all memberships and grab the oldest value to populate the custom field with it.</em></p>
  
  <p>I'm well versed in building custom extensions and working in custom code. This is for a Drupal 7 / CiviCRM site. Any ideas or direction?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-09T17:57:53.670Z
Comments.Text: Thinking aloud. Set up Views to access the log_civicrm_membership (or civicrm_membership_log) tables, and then make a block and set to show on summary page
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-21T19:13:07.487Z
Comments.Text: Hi Pete, Thanks for that idea. I think that might just work. I might even be able to use it to trigger a batch update to create an insert/update on a custom field as well. I will give it a spin and see how it works out. Cheers, Andrew
Comments.UserDisplayName: Andrew Wasson
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-21T23:26:46.540Z
Comments.Text: another more off-the-cuff thought would be to add a new field to eg Summary Fields or Synopsis to grab and show this date. also do you know about https://civicrm.org/extensions/contact-membership-logs
Comments.UserDisplayName: petednz - fuzion
Tags: <civimember><custom-fields><profile>
Title: Approach to dynamically filled custom field using member since date
ThreadText: # Approach to dynamically filled custom field using member since date
  
  (Asked by: username_0 on 2019-07-17)
  
  I've been thinking about how to best approach this and I'm stumped as to how to best go about it.
  
  I want to add a custom field to a profile that is rendered on the Contact Summary page. I would like to fill it dynamically with the value of the individual's earliest Member Since value.
  
  **NOTE:** *I say the earliest Member Since value because a bug in Civi has changed all Member Since values of currently active membership records to the date of the start of that membership record when they are renewed which ignores the concept that the individual may have had an earlier membership of a different type. The solution is to loop through all memberships and grab the oldest value to populate the custom field with it.*
  
  I'm well versed in building custom extensions and working in custom code. This is for a Drupal 7 / CiviCRM site. Any ideas or direction?
  
  **Tags:** civimember, custom-fields, profile
  
  > **Comments:**
  > **username_1**: Thinking aloud. Set up Views to access the log_civicrm_membership (or civicrm_membership_log) tables, and then make a block and set to show on summary page  
  > **username_0**: Hi Pete, Thanks for that idea. I think that might just work. I might even be able to use it to trigger a batch update to create an insert/update on a custom field as well. I will give it a spin and see how it works out. Cheers, username_0  
  > **username_1**: another more off-the-cuff thought would be to add a new field to eg Summary Fields or Synopsis to grab and show this date. also do you know about https://civicrm.org/extensions/contact-membership-logs  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2019-07-18. Score: 0
  
  Thinking out loud......
  
  * create an extension with perhaps an API that accepts a contact\_id as a param and returns the oldest membership start date
  * assuming you know in advance what the member since should be you could use the buildForm hook to change the value (using the API or doing the calculation in a a specific class)
  * alternatively add a little jQuery (using the CRM\_Core\_Region, see <https://docs.civicrm.org/dev/en/latest/framework/region/>) to the form that replaces the core value with the "correct" value using the API request?
  
  
  ---
  
  ### Answer by username_3 on 2019-07-17. Score: 0
  
  How immediately do you need this field's value to be set? If it can be delayed, I'd probably do this as a cron script that loops through all that aren't set yet and then sets its value.
  
  I'm assuming also you're familiar with the "View only" checkbox at the bottom of the custom field definition form - that would be how I'd create this field.
  
  
  ---
  
  