Skip to content

bmel:get-resource-by-id

Category: JSON · Returns: bmel:json

bmel:get-resource-by-id(resourceType: bmel:resource-type, id: bmel:any)

Description

Looks up an imported resource of the given resource type by its identifier and returns the complete resource instance as a JSON object — the record stored in Resources when it was imported from its DataSource.

id is matched against the resource's reference keys — its primary key, then its name field — the same way an object reference resolves. For an AI model catalog keyed by model_id and model_name, the model name "gpt-4o" sent in the request finds that model. Returns null when no resource of that type has that identifier.

The resource type is written with the #{ResourceType} notation and must be a resource type of the template the target Frame Type belongs to. In the BMEL editor, typing #{ lists those resource types; keep typing to filter the list. See Resource and field references operators.

Arguments

Parameter Type Required Description
resourceType bmel:resource-type The resource type to search, as #{ResourceType} (e.g. #{aimodel}).
id bmel:any The value of one of the resource's reference keys — its id or its name.

Example

Read one attribute of the resource with bmel:get-json-field — here, the input price per token of the model sent in the request:

bmel:get-json-field(
    bmel:get-resource-by-id(#{aimodel}, {invokeAgent:Request Payload}.$.model),
    #{input_cost_per_token})

← Back to BMEL Reference

Template dependency changes

Resource-type and attribute references written with #{Name} participate in mapping dependency validation, including nested calls. Removing or redefining a referenced dependency can invalidate the enclosing expression and trigger IntelliSense revalidation during editing or a Published-version fork. See ASBO dependencies in BMEL.