Advanced Portal Designer Documentation
Index

Agent Tools Reference

This page documents all the tools available to the APD Agent for portal development.

Viewing Available Tools

  1. Open Agent Development page
  2. Click Tools Available action
  3. View the list with name, description, and provider

Action Tools

list_actions

Returns a list of all existing actions.

Parameters: None

Returns: JSON array of actions with:

  • action - Action code
  • description - Action description
  • type - Action type (Html, Script, Data, etc.)

Example Usage:

"Show me all the actions in this portal"

get_action

Gets detailed information about a specific action.

Parameters:

Parameter Type Required Description
action string Yes Name of the action

Returns: JSON object with all action fields

Example Usage:

"What are the settings for the HOME action?"

new_action

Creates a new action.

Parameters:

Parameter Type Required Description
action string Yes Name of the new action
description string Yes Description of the action
type string Yes Action type. Recognized values: html, report, script, codeunit, blob, data.

Note: The new_action tool does not accept the "File Script" / "Html Script" action type. To create a File Script action, create an html action first and then change its Type field manually in BC, or use update_action to set the Type.

Returns: Confirmation message

Example Usage:

"Create a new HTML action called CUSTOMER-LIST for displaying customers"

update_action

Updates a field on an existing action.

Parameters:

Parameter Type Required Description
action string Yes Name of the action
field string Yes Field name to update
value string Yes New value for the field

Returns: Confirmation of update

Common Fields:

  • HTML/XML Template File - Template name
  • Description - Action description
  • Require Authentication - true/false
  • Security Profile - Profile code
  • Default - Set as default action

Example Usage:

"Set the HOME action to require authentication"

compile_action

Compiles a specific action.

Parameters:

Parameter Type Required Description
action string Yes Name of the action to compile

Returns: Confirmation

Example Usage:

"Compile the CUSTOMER-LIST action"

compile_all

Compiles all HTML actions.

Parameters: None

Returns: Confirmation

Example Usage:

"Compile all actions in the portal"

Template Tools

list_templates

Returns a list of all templates.

Parameters: None

Returns: JSON array with:

  • name - Template name
  • language - Language code

Example Usage:

"List all the templates"

search_templates

Search templates by name and HTML body. Returns templates whose name or HTML content contains the search string.

Parameters:

Parameter Type Required Description
search string Yes Substring to look for in template name or body

Returns: JSON array of matching templates

Example Usage:

"Find templates that include the header"

get_template

Gets the HTML content of a template.

Parameters:

Parameter Type Required Description
name string Yes Template name
language string No Language code (0 for default)

Returns: HTML content wrapped in code block

Example Usage:

"Show me the header template"

save_template

Saves HTML content to a template (creates if doesn't exist).

Parameters:

Parameter Type Required Description
name string Yes Template name
language string No Language code
text string Yes HTML content

Returns: Confirmation

Example Usage:

"Create a new template called 'footer' with copyright information"

Content Tools

list_content

Returns a list of all content items.

Parameters: None

Returns: JSON array with:

  • name - Content name
  • title - Content title
  • type - Content type
  • language - Language code
  • style - Display style
  • hostaction - Associated action

Example Usage:

"List all content items"

get_content

Gets the markdown content of a content item.

Parameters:

Parameter Type Required Description
name string Yes Content name
language integer No Language ID (0 for default)

Returns: Markdown content

Example Usage:

"Show me the privacy-policy content"

save_content

Saves markdown content (creates if doesn't exist).

Parameters:

Parameter Type Required Description
name string Yes Content name
language integer No Language ID
title string No Content title
type string No Content type
hostaction string No Host action code
markdown string Yes Markdown content

Returns: Confirmation

Example Usage:

"Create an FAQ content item with common questions"

Business Central Discovery Tools

get_tables

Searches for tables in Business Central by name.

Parameters:

Parameter Type Required Description
search string Yes Table name search pattern

Returns: JSON array with table information including:

  • Object ID - Table number
  • Object Name - Table name

Example Usage:

"Find tables related to sales"

get_fields

Gets all fields in a specific table.

Parameters:

Parameter Type Required Description
number integer Yes Table number

Returns: JSON array of fields with:

  • No. - Field number
  • FieldName - Field name
  • Type - Data type
  • And other field metadata

Example Usage:

"What fields are in the Customer table?"

Script Tools

get_script

Returns the AL script source of a Script-type (or File Script) action.

Parameters:

Parameter Type Required Description
action string Yes Name of the action

Returns: The AL script source

Example Usage:

"Show me the script behind the CHECKOUT action"

save_script

Saves and compiles the script of a Script-type action.

Parameters:

Parameter Type Required Description
action string Yes Name of the action
text string Yes AL script source

Returns: Confirmation (or compile errors)

Example Usage:

"Update the CHECKOUT action's script to validate the cart total before posting"

Security Tools

add_profile

Creates a Security Profile that can be used in the <?profile?> tag and on action security settings.

Parameters:

Parameter Type Required Description
profile string Yes Profile code
description string No Profile description

Returns: Confirmation

Example Usage:

"Add a security profile called PREMIUM for premium customers"

Tool Call Examples

Creating a Complete Action

When you ask the agent to create a page, it typically uses multiple tools:

User: "Create a customer list page showing name, city, and balance"

Agent Tool Calls:
1. get_tables('Customer')        → Finds table 18
2. get_fields(18)                → Gets available fields
3. new_action('CUSTOMER-LIST')   → Creates the action
4. save_template('customer-list', HTML with loop and fields)
5. update_action('CUSTOMER-LIST', 'HTML/XML Template File', 'customer-list')
6. compile_action('CUSTOMER-LIST')

Modifying Existing Templates

User: "Add a phone number column to the customer list"

Agent Tool Calls:
1. get_template('customer-list') → Gets current HTML
2. get_fields(18)                → Checks field exists
3. save_template('customer-list', updated HTML)
4. compile_action('CUSTOMER-LIST')

Building with Includes

User: "Create a header template and include it in the home page"

Agent Tool Calls:
1. save_template('header', header HTML)
2. get_template('home')          → Gets current home
3. save_template('home', HTML with <?parse('header')?>)
4. compile_action('HOME')

Special Content Items

ai.instructions

Create a content item named ai.instructions to provide the agent with project-specific guidelines. The agent includes this in every conversation.

ai.progress

The agent automatically maintains notes in a content item called ai.progress. This helps maintain context across sessions.

Best Practices

Clear Instructions

Be specific in your requests:

  • ✓ "Create an action called ORDER-LIST that shows sales orders with document number, customer name, and amount"
  • ✗ "Make an order page"

Iterative Development

Work in steps:

  1. Create basic structure
  2. Test and verify
  3. Add features incrementally
  4. Refine styling

Review Generated Code

Always review the generated:

  • Template HTML for correctness
  • Action settings
  • Security configuration