Answers.Body: <p>You could use the <a href="https://github.com/aelvan/Preparse-Field-Craft" rel="nofollow">Preparse</a> plugin to save the product ID part of your field in a new hidden field.</p>
  
  <p>Add a new "productId" Preparse field to your entry type with this code in the field's settings:</p>
  
  <pre><code>{{ entry.customField|split('-')|first }}
  </code></pre>
  
  <p>To update all existing entries, re-save them by going into Settings → Sections → Section Name and click Save.
  You can now set up a criteria model exactly like you mentioned in your question, except that you now use the
  Preparse field as your custom field parameter:</p>
  
  <pre><code>{% set entries = craft.entries.section('sectionName').productId(pluginIds) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-20T11:40:52.033Z
Answers.Text: This could definitely work but I'd love to populate two columns from the one dropdown instead, inside the plugin I've created.
Answers.UserDisplayName: Clive Portman
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-22T07:13:09.220Z
Answers.Text: Well.. I think you should better ask a new question for this problem. I'm not sure I understand how many plugins are involved and how they save.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-16T13:30:39.507Z
Answers.LastActivityDate: 2015-10-16T13:30:39.507Z
Answers.UserDisplayName: carlcs
Body: <p>My entries have a field containing a third-party product id and a price, separated by a hyphen, like so:</p>
  
  <pre><code>p666a-12.99
  </code></pre>
  
  <p>In the template, a plugin is returning me some product ids, and I want to return all entries containing those product ids. I know I can fetch all entries, reduce the custom field down to the product id and compare it to the product ids returned from the plugin, but that seems a bit tardy.</p>
  
  <p>Can I filter my entries using the custom field directly?</p>
  
  <pre><code>{# pluginIds = 'p666a, p678a' #}
  {% set entries = craft.entries.section('sectionName').customField(pluginIds) %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-16T13:21:46.377Z
Comments.Text: What's the reason for the product ID and the price being saved to the same database column? Can you change this?
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-16T15:42:59.287Z
Comments.Text: +1 to @carlcs. If at all possible, I'd separate them out into different fields. :)
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-20T11:40:04.610Z
Comments.Text: The plugin presents the client with a dropdown list of products from a third-party, and I think a dropdown is the best way to do that. But, yes, ideally I'd populate two database columns using that field - any examples for doing that from a dropdown, within a plugin?
Comments.UserDisplayName: Clive Portman
Tags: <entries><custom-field><contains>
Title: Return entries where custom field partially contains
ThreadText: # Return entries where custom field partially contains
  
  (Asked by: username_0 on 2015-10-16)
  
  My entries have a field containing a third-party product id and a price, separated by a hyphen, like so:
  
  ```
  p666a-12.99
  
  ```
  
  In the template, a plugin is returning me some product ids, and I want to return all entries containing those product ids. I know I can fetch all entries, reduce the custom field down to the product id and compare it to the product ids returned from the plugin, but that seems a bit tardy.
  
  Can I filter my entries using the custom field directly?
  
  ```
  {# pluginIds = 'p666a, p678a' #}
  {% set entries = craft.entries.section('sectionName').customField(pluginIds) %}
  
  ```
  
  **Tags:** entries, custom-field, contains
  
  > **Comments:**
  > **username_1**: What's the reason for the product ID and the price being saved to the same database column? Can you change this?  
  > **username_2**: +1 to @username_1. If at all possible, I'd separate them out into different fields. :)  
  > **username_0**: The plugin presents the client with a dropdown list of products from a third-party, and I think a dropdown is the best way to do that. But, yes, ideally I'd populate two database columns using that field - any examples for doing that from a dropdown, within a plugin?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-10-16. Score: 4 | Accepted answer
  
  You could use the [Preparse](https://github.com/aelvan/Preparse-Field-Craft) plugin to save the product ID part of your field in a new hidden field.
  
  Add a new "productId" Preparse field to your entry type with this code in the field's settings:
  
  ```
  {{ entry.customField|split('-')|first }}
  
  ```
  
  To update all existing entries, re-save them by going into Settings → Sections → Section Name and click Save.
  You can now set up a criteria model exactly like you mentioned in your question, except that you now use the
  Preparse field as your custom field parameter:
  
  ```
  {% set entries = craft.entries.section('sectionName').productId(pluginIds) %}
  
  ```
  
  > **Comments:**
  > **username_0**: This could definitely work but I'd love to populate two columns from the one dropdown instead, inside the plugin I've created.  
  > **username_1**: Well.. I think you should better ask a new question for this problem. I'm not sure I understand how many plugins are involved and how they save.  
  
  ---
  
  