You can use metafields to store configuration values for your location rule function. Metafields provide greater flexibility to use functions, and are a prerequisite to creating a merchant user interface for configuring functions. > Beta: > Location rules is a new feature that's only available by request. Reach out to [Shopify Plus Support](https://help.shopify.com/en/support/plus) to know more about your eligibility and the requirements for the beta program. ## What you'll learn In this tutorial, you'll learn how to do the following tasks: - Create a metafield definition. - Add metafields to your GraphQL input query. - Use metafield values in your function logic. ## Requirements - You've completed the [Getting started with building location rules](/docs/apps/build/orders-fulfillment/order-routing-apps/location-rules/build-location-rule-function) tutorial. ## Step 1: Create the metafield definition To make your function reusable, you can replace hardcoded values in your function with metafield values. For security reasons, it's recommended to [create a metafield definition under a reserved namespace](/docs/apps/build/custom-data/ownership#create-metafield-definitions-with-reserved-namespaces). The Shopify admin requires additional permissions to handle reserved namespaces in order to broker metafield changes on behalf of your application. Update `shopify.server.ts` file with the following code inside the `afterAuth` hook to create a metafield definition and grant additional access to Shopify admin:

Your code should look like this:

## Step 2: Configure the function After you create the metafield definition, you can update your function to use metafield values set by the user. Update your [input query](/docs/apps/build/functions/input-output/metafields-for-input-queries) to request a metafield value on the created location rule, which is the [function owner](/docs/apps/build/functions/input-output/metafields-for-input-queries#how-it-works) for this function API. You can then use that value in your function logic. 1. Navigate to your function in `extensions/location-rule`.

1. Replace the code in the `src/run.graphql` file with the following code. This update to the input query adds a metafield from the `locationRule` object, which is the function owner. The query differs slightly in Rust and JavaScript due to code generation requirements.

1. If you're using JavaScript, then run the following command to regenerate types based on your input query:

1. Replace the `src/run.rs` or `src/run.js` file with the following code. This update includes parsing the JSON metafield value, and using values from that JSON in the function logic instead of hardcoded values. This change is automatically reflected as long as you're running `dev`.

## Next steps - Build a [location rule user interface](/docs/apps/build/orders-fulfillment/order-routing-apps/location-rules/build-ui) using [Admin UI extensions](/docs/api/admin-extensions). - Learn how to use [variables](/docs/apps/build/functions/input-output/use-variables-input-queries) in your input query.