This is an example of an ExternalLookup configuration that uses WSDataSource and DataTableRenderMode. It also uses ExternalLookup.CopyElements.
If your request uses a body, you should also define a function within the Form/CustomScript and name it ExternalLookupCustomFunction_[FieldInternalName].
// For example if `searchText` was set to `Aricoma`, then the JS function below will produce a request body that would look like this: { "obchodniJmeno": "Aricoma" }
function ExternalLookupCustomFunction_s_supplierLookup(searchText) {
if (searchText.match(/\d+/)) return { ico: [searchText] };
return { obchodniJmeno: searchText };
}
{
"DataSourceType": "WS",
"DataSourceConfiguration": {
"Url": "https://ares.gov.cz/ekonomicke-subjekty-v-be/rest/ekonomicke-subjekty/vyhledat",
"Cache": "24:0:0",
"RequestType": "REST",
"MethodName": "POST",
"ResultSetItems": "ekonomickeSubjekty",
"ResultSetType": "JSON",
"ResultSet": [
{
"Name": "Nazev",
"Path": "obchodniJmeno"
},
{
"Name": "ICO",
"Path": "ico"
},
{
"Name": "Nazev_ulice",
"Path": "sidlo.nazevUlice"
},
{
"Name": "Nazev_obce",
"Path": "sidlo.nazevObce"
}
]
},
"IndexValue": {
"Expression": "{ID}"
},
"TextValue": {
"Expression": "{Nazev}"
},
"DataTableElements": [
{
"ColumnTitle": "Název",
"Expression": "{Nazev}"
},
{
"ColumnTitle": "IČO",
"Expression": "{ICO}"
},
{
"ColumnTitle": "Ulice",
"Expression": "{Nazev_ulice}"
},
{
"ColumnTitle": "Obec",
"Expression": "{Nazev_obce}"
}
],
"CopyElements": [
{
"TargetElement": "s_supplierId",
"Expression": "{ICO}"
},
{
"TargetElement": "s_supplierName",
"Expression": "{Nazev}"
},
{
"TargetElement": "s_supplierIdentificationNumber",
"Expression": "{ICO}"
},
{
"TargetElement": "s_supplierTaxIdentNumber",
"Expression": "CZ{ICO}"
}
],
"RenderMode": "DataTable"
}
Here is an example response from the configured web service to help clarify the example above.
Notice how ResultSetItems specifies that the items are located under the ekonomickeSubjekty property. Also notice how ResultSet links properties within each item to an expression token that is than used in DataTableElements.
{
"pocetCelkem": 3,
"ekonomickeSubjekty": [
{
"ico": "04615671",
"obchodniJmeno": "Aricoma a.s.",
"sidlo": {
"nazevObce": "Praha",
"nazevUlice": "Vinohradská"
}
},
{
"ico": "04772148",
"obchodniJmeno": "Aricoma Enterprise Cybersecurity a.s.",
"sidlo": {
"nazevObce": "Praha",
"nazevUlice": "Voctářova"
}
},
{
"ico": "47117087",
"obchodniJmeno": "Aricoma Digital s.r.o.",
"sidlo": {
"nazevObce": "Praha",
"nazevUlice": "Vinohradská"
}
}
]
}