FieldsRaven developer docs
  • Welcome!
  • Quick Start
  • App embeds
    • Sitemap manager
    • Customer Birthday Popup
  • FAQ
  • Code examples
    • Create a single_line_text_field metafield
    • Delete a metafield
    • Create a product_reference metafield
    • Create a list.product_reference metafield
    • Create a json metafield
    • Create multiple metafields (aka flock)
  • Example features
    • Customer Birthday Popup (WIP)
    • Sitemap Manager (WIP)
    • Page SEO Editor (TBD)
    • Product FOMO (TBD)
    • Show off live traffic (TBD)
    • Collect custom customer attributes
    • Wish List
    • Customer registration with custom attributes
    • Customer Product Registration
  • Troubleshooting
  • Klaviyo
  • Airtable
Powered by GitBook
On this page
  1. Code examples

Create a list.product_reference metafield

PreviousCreate a product_reference metafieldNextCreate a json metafield

Last updated 1 year ago

The type of the metafield you're going to create depends on the Raven carrying the message. If the value you're sending doesn't match the value type expected, the request will result in an error.

List metafields enable you to store multiple values in a single metafield. The maximum number of values that can be stored in a metafield list is 128. The value must be provided as a JSON array.

<!-- JavaScript + Liquid -->
<script type="text/javascript">
  fieldsRavenSubmit = (value) => {
    const ravenObj = {%- render 'raven-mac-gen', resource_id: customer.id, raven_id: 'TBD' -%}
    const valueObj = { value: value };
    const requestParams = { raven: Object.assign({}, ravenObj, valueObj) };
    const response = fetch('/apps/raven/create_metafield', {
      method: 'PUT',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify(requestParamsOne)
    })

    response
      .then(res => res.json())
      .then(resJson => console.log('resJson: ', resJson))
  }
</script>

<!-- HTML -->
<button id="fieldsraven-demo" onclick="ravenSubmit('[product_1_id, product_2_id]')">Send the Raven!</button>
<!-- JavaScript + Liquid -->
<script type="text/javascript">
  fieldsRavenSubmit = (value) => {
    const ravenObj = {%- render 'raven-mac-gen', resource_id: customer.id, raven_id: 'TBD' -%}
    const valueObj = { value: value };
    const requestParams = Object.assign({}, ravenObj, valueObj);
    const response = FieldsRaven.send(requestParams);
    response.then(res => {
      if (res.status === 200) {
        console.log('🎉', res.json)
      } else {
        console.error('😞', res)
      }
    })
    .catch(e => console.error(e));
  }
</script>

<!-- HTML -->
<button id="fieldsraven-demo" onclick="ravenSubmit('[product_1_id, product_2_id]')">Send the Raven!</button>