Examples - AFS

AFS Integration Guide

Product
AFS
AFS_Version
7.7
Category
Reference Guide

Considering this AFS result:

var result = {
"docId": 3376,
"uri": "urn:dita:T15331.dita",
"title": [
{
"afs:t": "KwicString",
"text": "Declaration Example"
}
],
"layerReplies": {
"reply": [
{
"layer": "USER_2",
"reply": {
"docId": 3376,
"uri": "",
"clientData": [
{
"contents": "<afs:entry>XML Stuff</afs:entry>",
"id": "breadcrumb",
"mimeType": "text/xml"
}
]
}
},
{
"layer": "USER_4",
"reply": {
"docId": 3376,
"uri": "",
"clientData": [
{
"contents": {
"entry": [
{
"topics": [
{
"uri": "urn:dita:T12748-1.49.dita",
"label": "Configuring The Indexing Filter"
}
]
}
]
},
"id": "breadcrumb",
"mimeType": "application/json"
}
]
}
}
]
}
};

The following call will extract the USER_2 layer:

console.log(AFSWidget.sdk.search.reply.util.extractLayer('USER_2', result));

var result = {
"docId": 3376,
"uri": "urn:dita:T15331.dita",
"title": [
{
"afs:t": "KwicString",
"text": "Declaration Example"
}
],
"layerReplies": {
"reply": [
{
"layer": "USER_2",
"reply": {
"docId": 3376,
"uri": "",
"clientData": [
{
"contents": "<afs:entry>XML Stuff</afs:entry>",
"id": "breadcrumb",
"mimeType": "text/xml"
}
]
}
},
{
"layer": "USER_4",
"reply": {
"docId": 3376,
"uri": "",
"clientData": [
{
"contents": {
"entry": [
{
"topics": [
{
"uri": "urn:dita:T12748-1.49.dita",
"label": "Configuring The Indexing Filter"
}
]
}
]
},
"id": "breadcrumb",
"mimeType": "application/json"
}
]
}
}
]
}
};

Take care about unexisting layers:

console.log(AFSWidget.sdk.search.reply.util.extractLayer('USER_1', result));

null