> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Parser code

> Parser code

This element lets you **display HTML text**, including data from the database as parser variables.
The database query is defined using a [line-based query syntax][1].

The body fields contain the HTML text to use for the element.

The results from the query will be stored in the parser as the name of the queried fields, for example, "ticket.title", "ticket.id", "customer.display\_name".

<Tip>
  Try using `%PARSER_TREE%` to view all the available values.
</Tip>

This component also supports ajax.

## Example

```javascript theme={null}
<script language='JavaScript' src='/JavaScript/ajax.js'></script>
<script language='JavaScript' src='/JavaScript/xml.js'></script>
<script>

function `fetchStuff()` {
  var message = "<someCommand ejScriptIncludeId='testAjax'>\n";
  message += "  <someNode>100</someNode>\n";
  message += "  <someNode>200</someNode>\n";
  message += "</someCommand>\n";

  ajax_addRequest("myTestControl", "EjScript", message)
}

function EjScript_processResponse(p_xmlNode) {
  var name = getAttribute(p_xmlNode, "name");
  var elem = document.getElementById("myTestField");
  elem.value = name + ": ";

  for (var i = 0; i < getLength(p_xmlNode.childNodes); i++) {
      if (getNodeName(getChild(p_xmlNode, i)) == "result")
        elem.value = elem.value + getText(getChild(p_xmlNode, i)) + " ";
  }
}
</script>

<input type="text" name="myTestField" id="myTestField" value="">
<input type="submit" name="testScript"  id="testScript" value="testScriptonClick=" fetchStuff(); return false;">
```

The function `EjScript_processResponse(p_xmlNode)` is called by the ajax framework, and if you have several such ajax based controls, you can test for a name match in the xml so you know what control to update.

The name is what you used in `ajax_addRequest("myTestControl", "EjScript", message)`.

A CRMScript is run by the ajax application on the server, you select which script in the XML request.

The CRMScript may do something like this:

```crmscript theme={null}
#setLanguageLevel 2;

print("  <result>\n");
print("Number of nodes: " + getVariable("nodes.length"));
print("  </result>\n");

for (Integer i = 0; i < getVariable("nodes.length").toInteger(); i++) {
  print("  <result>\n");
  print("Node " + i.toString() + ": " + getVariable("nodes." + i.toString() + ".name") + "-" + getVariab("nodes." + i.toString() + ".value"));
  print("  </result>\n");
}
```

[1]: ../custom-screens/blogic-query-syntax


## Related topics

- [MacroParameter](/en/automation/crmscript/reference/CRMScript.Native.MacroParameter.md)
- [Parser](/en/automation/crmscript/reference/CRMScript.Native.Parser.md)
- [SuperOffice.WebApi.Agents.ICustomerServiceAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.ICustomerServiceAgent.md)
- [SuperOffice.WebApi.Agents.CustomerServiceAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.CustomerServiceAgent.md)
- [Ticket](/en/automation/crmscript/reference/CRMScript.Native.Ticket.md)
- [Reply to customer](/en/automation/crmscript/howto/request/reply.md)
