Answers.Body: <p>SearchKit works by using the underlying data about how tables connect to each other.  If that connection doesn't exist, SK can't join the tables.</p>
  <p>I believe the underlying API supports joins on arbitrary fields, but I'm not 100%.  If so, you can modify the SearchKit query in the <code>civicrm_saved_search</code> table.</p>
  <p>You haven't specified the type of custom field you're using - but I suspect it's an alphanumeric multiple-choice question.  Consider making a new entity &quot;Mentoring Area&quot;, then use Entity Reference custom fields. While this normally requires an extension, it should be doable with the <a href="https://github.com/systopia/de.systopia.eck" rel="nofollow noreferrer">Entity Creation Kit</a> extension.</p>
  <p>Entity Reference fields automatically create joins between the custom field and the entity for SearchKit. So you would join from mentee to entity to mentor, or vice versa.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-06-11T16:01:34.067Z
Answers.Text: Thanks Jon, those are two really useful leads. We're trying to avoid complexity so will checkout the saved_search table and see if we can add the joins there. Thank you!
Answers.UserDisplayName: Darren
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-06-06T13:51:00.850Z
Answers.LastActivityDate: 2024-06-06T13:51:00.850Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I would like to help users to find matching &quot;Mentor&quot; contacts for &quot;Mentees&quot; based on values held in custom data fields and providing a tab on the Contact Summary called &quot;Matching Mentors&quot;.</p>
  <p>The Mentees complete a drop down list field called &quot;Mentee Area&quot;, which is part of a <strong>multi-value</strong> custom data group. They can submit multiple Mentor requests.</p>
  <p>The Mentors complete a field called &quot;Mentor Area&quot; which uses the same values as the list above, but is a different custom field in a <strong>single value</strong> custom data group.</p>
  <p>So I need to combine all the &quot;Mentee Area&quot; values a Mentee has submitted, then use these as a filter in the &quot;Matching Mentors&quot; searchkit, i.e. &quot;Mentor Area&quot; in &quot;list,of,mentee,areas&quot;.</p>
  <p>I've got as far as creating the searchkit and form, then exposing this under the contact summary, but I can't see how to pass the contextual filter of &quot;Mentee Areas&quot; to the searchkit.</p>
  <p>Perhaps I can achieve this using the &quot;filters&quot; attribute of the form markup with a custom token?</p>
  <p>Maybe we're pushing serckit and formbuilder too far and need to bite the bullet and create an extension?</p>
  <p>I hope this makes sense. Any help or advice, much appreciated as always.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-06-05T19:34:23.623Z
Comments.Text: Adding an example may help folk including me picture what you are doing more quickly.
Comments.UserDisplayName: petednz - fuzion
Tags: <searchkit><formbuilder>
Title: How can I use SearchKit and FormBuilder to show a table of matching contacts under Contact Summary by comparing custom field values?
ThreadText: # How can I use SearchKit and FormBuilder to show a table of matching contacts under Contact Summary by comparing custom field values?
  
  (Asked by: username_0 on 2024-06-05)
  
  I would like to help users to find matching "Mentor" contacts for "Mentees" based on values held in custom data fields and providing a tab on the Contact Summary called "Matching Mentors".
  
  The Mentees complete a drop down list field called "Mentee Area", which is part of a **multi-value** custom data group. They can submit multiple Mentor requests.
  
  The Mentors complete a field called "Mentor Area" which uses the same values as the list above, but is a different custom field in a **single value** custom data group.
  
  So I need to combine all the "Mentee Area" values a Mentee has submitted, then use these as a filter in the "Matching Mentors" searchkit, i.e. "Mentor Area" in "list,of,mentee,areas".
  
  I've got as far as creating the searchkit and form, then exposing this under the contact summary, but I can't see how to pass the contextual filter of "Mentee Areas" to the searchkit.
  
  Perhaps I can achieve this using the "filters" attribute of the form markup with a custom token?
  
  Maybe we're pushing serckit and formbuilder too far and need to bite the bullet and create an extension?
  
  I hope this makes sense. Any help or advice, much appreciated as always.
  
  **Tags:** searchkit, formbuilder
  
  > **Comments:**
  > **username_1**: Adding an example may help folk including me picture what you are doing more quickly.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2024-06-06. Score: 3
  
  SearchKit works by using the underlying data about how tables connect to each other. If that connection doesn't exist, SK can't join the tables.
  
  I believe the underlying API supports joins on arbitrary fields, but I'm not 100%. If so, you can modify the SearchKit query in the `civicrm_saved_search` table.
  
  You haven't specified the type of custom field you're using - but I suspect it's an alphanumeric multiple-choice question. Consider making a new entity "Mentoring Area", then use Entity Reference custom fields. While this normally requires an extension, it should be doable with the [Entity Creation Kit](https://github.com/systopia/de.systopia.eck) extension.
  
  Entity Reference fields automatically create joins between the custom field and the entity for SearchKit. So you would join from mentee to entity to mentor, or vice versa.
  
  > **Comments:**
  > **username_0**: Thanks Jon, those are two really useful leads. We're trying to avoid complexity so will checkout the saved_search table and see if we can add the joins there. Thank you!  
  
  ---
  
  