Advanced Portal Designer Documentation
Index

Template Issues

This page provides detailed troubleshooting for template-specific issues, including tag syntax, data binding, and rendering problems.

Tag Syntax Issues

Tags Displayed as Text

Problem: Tags like <?field(Name)?> appear literally instead of being processed.

Solutions:

  1. Recompile the action
    • Open the action
    • Click Compile
    • Test again
  2. Check tag syntax
   <!-- Wrong -->
   <? field(Name) ?>    <!-- Space after <? -->
   <?Field(Name)?>      <!-- Capital F -->
   <?field(Name)>       <!-- Missing ? at end -->
   
   <!-- Correct -->
   <?field(Name)?>
  1. Verify action type supports templates
    • Must be HTML, HTML Script, or similar
    • Data actions don't process HTML templates

Unclosed Tag Errors

Problem: Compilation fails with unclosed tag error.

Solutions:

Check for matching pairs:

<!-- Unclosed open -->
<?open(Customer)?>
<!-- Missing <?close(Customer)?> -->

<!-- Unclosed loop -->
<?loop(Customer,'-')?>
<!-- Missing <?endloop(Customer)?> -->

<!-- Unclosed conditional -->
<?auth?>
<!-- Missing <?endif?> -->

Fix by adding closing tags. Note: <?close?> takes the table as a parameter; <?auth?>, <?profile?>, <?if?> and related conditional blocks all close with <?endif?>:

<?open(Customer)?>
<!-- Content -->
<?close(Customer)?>

<?loop(Customer,'-')?>
<!-- Content -->
<?endloop(Customer)?>

<?auth?>
<!-- Content -->
<?endif?>

Block Tags Closed in Wrong Order

Problem: Block tags closed in wrong order. (These are block boundaries on the same page — APD itself does not allow nesting one <??> tag inside another's parameter list.)

<!-- Wrong order -->
<?open(Customer)?>
<?loop(Customer,'-')?>
<?close(Customer)?>                <!-- Should be endloop first -->
<?endloop(Customer)?>

<!-- Correct order -->
<?open(Customer)?>
<?loop(Customer,'-')?>
<?endloop(Customer)?>
<?close(Customer)?>

Data Binding Issues

Field Shows Empty

Problem: <?field(Name)?> shows nothing.

Diagnostic steps:

  1. Is data source open?
   <!-- Wrong - no open tag -->
   <?field(Customer,Name)?>

   <!-- Correct -->
   <?open(Customer)?>
   <?field(Customer,Name)?>
   <?close(Customer)?>
  1. Is record positioned?
   <!-- In loop, record is positioned -->
   <?loop(Customer,'-')?>
   <?field(Customer,Name)?>      <!-- Works -->
   <?endloop(Customer)?>

   <!-- Outside loop, need filter to single record -->
   <?open(Customer)?>
   <?filter(Customer,"No.",10000)?>
   <?field(Customer,Name)?>      <!-- Works if record exists -->
   <?close(Customer)?>
  1. Does field name match exactly? Field-tag arguments are (Table, Field) — table name first, then the exact BC field name. Names containing spaces or special characters need double quotes.
   <!-- Wrong - missing table -->
   <?field(Name)?>

   <!-- Wrong - field doesn't exist on Customer -->
   <?field(Customer,"Customer Name")?>

   <!-- Correct - use exact BC field name, quote when it has spaces/punctuation -->
   <?field(Customer,Name)?>
   <?field(Customer,"Name 2")?>
   <?field(Customer,"No.")?>

Wrong Table Name

Problem: No data from table.

<!-- Wrong table names -->
<?open(Customers)?>            <!-- Should be Customer -->
<?open(SalesHeader)?>          <!-- Should be Sales Header -->
<?open(Sales Header)?>          <!-- Unquoted name with space -->

<!-- Correct table names -->
<?open(Customer)?>
<?open("Sales Header")?>

Use the exact BC table name. Quote names that contain spaces or special characters with double quotes.

Filter Not Working

Problem: Filter doesn't restrict records.

Check filter syntax: <?filter?> takes 3 arguments — Table, Field, FilterExpression. The operator is part of the expression, not a separate argument.

<!-- Wrong: 4-argument form, separate operator -->
<?filter(Customer,"No.",=,10000)?>
<?filter(Customer, "No.", =, 10000)?>   <!-- Extra spaces also break parsing -->

<!-- Correct: 3-argument form, operator inside the value -->
<?filter(Customer,"No.",10000)?>           <!-- equality is implicit -->
<?filter("Job Task","ICA Status",'<>FINISHED')?>
<?filter(Item,"Unit Price",'>100')?>

Filter expression operators (used inside the value string, BC filter syntax):

Operator Meaning Example
(none) Equals <?filter(Item,Type,Service)?>
<> Not equals '<>FINISHED'
> < >= <= Comparison '>100', '<='..today()
&#|; OR 'Service&#|;Resource'
.. Range '10..20'
* Wildcard 'Smith'
& AND on same field '>10&<100'

Check value: Use expression functions (e.g. today(), Parm('id')) inside parameters — do not nest <??> tags.

<!-- String value -->
<?filter(Customer,Name,Contoso)?>

<!-- Numeric value -->
<?filter("Sales Header",Amount,'>1000')?>

<!-- Date value (today() expression, NOT a nested <?today?> tag) -->
<?filter("Sales Header","Order Date",'>='..today())?>

Loop Returns No Records

Problem: Loop produces no output.

Diagnostic:

<?open(Customer)?>
<?loop(Customer,'-')?>
    <p>Found: <?field(Customer,Name)?></p>
<?endloop(Customer)?>
<?close(Customer)?>

If nothing shows:

  1. Check if table has records
    • Verify in BC directly
    • Remove filters temporarily
  2. Check security filters
    • Test with admin user
    • Review Security Setup
  3. Check template filters
    • Remove filters one by one
    • Verify filter values
  4. Add debug output
   <?open(Customer)?>
   <p>Before loop</p>
   <?loop(Customer,'-')?>
       <p>In loop: <?field(Customer,"No.")?></p>
   <?endloop(Customer)?>
   <p>After loop</p>
   <?close(Customer)?>

Conditional Logic Issues

If Condition Always True/False

Problem: <?if?> doesn't work as expected.

Check condition syntax: The <?if?> tag takes (Table, Field, Operator, Value) directly — do not nest a <?field?> tag inside it.

<!-- Checking field value -->
<?if(Customer,Blocked,'=',true)?>
    Blocked
<?endif?>

<!-- Authentication check (use <?auth?>, not <?if(authenticated)?>) -->
<?auth?>
    Logged in
<?endif?>

<!-- Comparing values -->
<?if(Customer,"Balance (LCY)",'>',0)?>
    Has balance
<?endif?>

Common mistakes:

<!-- Wrong - missing table name -->
<?if(Blocked,'=',true)?>

<!-- Wrong - nested <?field?> tag inside <?if?> -->
<?if(<?field(Customer,Blocked)?>,'=',true)?>

<!-- Wrong - <?if?> needs four parameters -->
<?if(authenticated)?>

<!-- Correct - Table, Field, Operator (in single quotes), Value -->
<?if(Customer,Blocked,'=',true)?>
<?if(Customer,"E-Mail",'<>','')?>   <!-- Check if E-Mail is not empty -->

Else Not Working

Problem: <?else?> content doesn't show.

<!-- Check structure -->
<?auth?>
    <p>Logged in</p>
<?else?>
    <p>Not logged in</p>
<?endif?>        <!-- Must have endif -->

Block Nesting Confused

Problem: Sibling conditional blocks give wrong results when stacked.

<!-- Block structure: <?auth?> contains a <?profile?> block, each closed by its own <?endif?> -->
<?auth?>
    <?profile(ADMIN)?>
        <p>Admin</p>
    <?else?>
        <p>User</p>
    <?endif?>        <!-- Closes the <?profile?> block -->
<?else?>
    <p>Guest</p>
<?endif?>            <!-- Closes the <?auth?> block -->

"Nested blocks" here means one block contains another in the template flow. APD still does not allow nesting one <??> tag inside the parameter list of another (e.g. <?if(<?profile?>)?> is invalid).

Parse / Include Issues

APD uses <?parse(TemplateName)?> to inline another template — there is no <?include?> tag.

Parse Not Found

Problem: <?parse(template)?> shows nothing or errors.

Solutions:

  1. Check template name
    • Use the exact template Name as stored in the APD Template list
    • Check spelling and any language sub-path
  2. Check template exists
    • Verify the template exists in the Templates list
    • The host action recompiles whenever you change a parsed template, so make sure that recompile succeeded
  3. Check syntax
   <?parse(header)?>

Parsed Content Shows Raw

Problem: Tags inside the parsed template appear as literal text.

Solution: Recompile the parent action — <?parse?> is resolved at compile time and the included tags are inlined into the parent's compiled instructions.

Circular Parse

Problem: Template A parses B, which parses A.

Solution: Remove the circular reference. Parses should form a tree, not a cycle.

Special Character Issues

HTML Entities in Output

Problem: &amp; instead of & in output.

Solutions:

  • Check if field contains HTML entities
  • Use appropriate encoding/decoding
  • Check data source

Quotes Breaking HTML

Problem: Quotes in data break HTML attributes.

<!-- Problematic -->
<input value="<?field(Item,Description)?>">
<!-- If Description contains a literal ", the HTML attribute breaks -->

<!-- Solution - use single quotes around the attribute or HTML-encode the value -->
<input value='<?field(Item,Description)?>'>

Special Characters in Filter

Problem: Filter fails with special characters. APD's filter parameters accept expressions — use the ping() expression for a single quote and the .. operator to concatenate strings.

<!-- May break - literal apostrophe inside the parameter -->
<?filter(Customer,Name,O'Brien)?>

<!-- Safer - build the value with ping() for the apostrophe -->
<?filter(Customer,Name,'O'..ping()..'Brien')?>

<!-- Or pass via a URL parameter -->
<?filter(Customer,"No.",Parm('custno'))?>

Performance Issues

Too Many Loops

Problem: Page slow due to nested loops.

<!-- Slow - nested loops multiply queries -->
<?loop(Customer,'-')?>
    <?loop("Sales Header",'-')?>
        <?loop("Sales Line",'-')?>
        <?endloop("Sales Line")?>
    <?endloop("Sales Header")?>
<?endloop(Customer)?>

Solutions:

  • Add restrictive filters
  • Flatten structure if possible
  • Use pagination

Too Many Fields

Problem: Selecting many fields slows page.

Solution: Only include needed fields.

Large Record Sets

Problem: Loop over thousands of records.

Solutions:

<!-- Add filter -->
<?filter(Customer,Blocked,No)?>

<!-- Use top limit -->
<!-- Paginate via the closing tag: <?endloop(Table,Step,PageSize)?> -->
<?loop(Customer,'-')?>
    ...
<?endloop(Customer,1,10)?>

Debugging Tips

Add Debug Output

<!-- Temporarily add markers -->
<p style="color:red">DEBUG: Before open</p>
<?open(Customer)?>
<p style="color:red">DEBUG: After open</p>
<?loop(Customer,'-')?>
<p style="color:green">DEBUG: In loop - <?field(Customer,"No.")?></p>
<?endloop(Customer)?>
<p style="color:red">DEBUG: After loop</p>
<?close(Customer)?>

Check Compiled Output

If possible, review the compiled template to see how tags are processed.

Test Incrementally

  1. Start with minimal template
  2. Add one element at a time
  3. Test after each addition
  4. Identify which element causes issue

Use Browser Developer Tools

  1. Open F12 Developer Tools
  2. Check Console for JavaScript errors
  3. Check Network for failed requests
  4. Inspect HTML for malformed markup