How-to
Article MarkdownReport an error

How to Get a Record from Custom Data by Search Criteria?

When your scenario needs to find an existing record (e.g. store by city, client by email, VIP by phone), use the custom_modules__get action. It searches by values from user state variables and saves the result to a variable for use in later blocks.


When Needed

  • User selects a city — you need to show a list of stores from Custom Data.
  • User enters email or phone — you need to check VIP status or get client data.
  • You need to check if a record exists with certain values and branch the scenario accordingly.

What's Important to Know

  • custom_modules__get — action for searching and getting a record from Custom Data.
  • Before use, you need to save field values for search in the user state.
  • Search is performed by values from variables of type "model_name:field_name".
  • After getting the record, you can output its attributes in a message block.

Prerequisites


Step-by-Step Instructions

Preparing Search Criteria

  1. In the scenario, add blocks to collect data to search by:
    • "Wait for Response" — for entering search value
    • "Message with Keyboard" — for selection from options
  2. Save the value to a variable of type "model_name:field_name" (for example, customer:email, product:code).

Example: To search by the "email" field, save the value to the customer:email variable.

Configuring Action

  1. Add an "Action" block to the scenario after search criteria collection blocks.
  2. In the "Action" block settings, select the custom_modules__get function.
  3. In the configuration field (JSON), enter parameters:
{
  "module_name": "customer",
  "set_to": "customer"
}
  • module_name — name of the model with the custom table (for example, "customer", "product")
  • set_to — name of the variable where the found record will be saved (for example, "customer", "found_product")
  1. Save changes in the action and scenario.

Using Retrieved Record

After getting the record, you can output its attributes in a message block using the variable from set_to. For example, if set_to = "customer", you can use {{customer:name}} or {{customer:phone}} to output field values.


Usage Example

Scenario:

  1. "Wait for Response" block → user enters email, saved to customer:email
  2. "Action" block with custom_modules__get → searches for record by customer:email, saves to customer
  3. "Message" block → outputs {{customer:name}} and {{customer:phone}}

Typical Scenarios

Scenario Model fields Sequence
Stores catalog city, address, lang_code User selects city → get by filters → show stores list
VIP check email, phone, vip_status User enters email/phone → get → show VIP benefits or standard flow
Categories for routing id, first_level, last_level, name Inline buttons with callback_data = id → get by id → route to branch

Important Notes

  • Before using custom_modules__get, be sure to save field values for search in user state variables.
  • If the record is not found, the variable from set_to will be empty.
  • You can use multiple fields for search simultaneously — the system will find a record that matches all criteria.

What Happens After

After executing the custom_modules__get action, the found record is saved to the variable specified in set_to. The record becomes available for use in subsequent scenario blocks. If the record is not found, the variable will be empty.


How to Verify It Worked

  • Check that search values are saved to variables of type "model_name:field_name".
  • Make sure the model name in module_name matches an existing model.
  • Test the scenario and check that the record is found and saved to the variable.
  • Check that record attributes are available for output.

Using your own AI agent?Install the open skill so your AI agent can work with current official ConnectiveOne documentation.Get the skillNeed support?Couldn’t find the answer or need help from the ConnectiveOne team? Create a request in Client Portal.Create a request