Hi,
We are trying to build functionality to populate drop-down, radio button and checkbox choice values.
This particular Database API (which we don't have control over) returns data in the following format:
JSON{
"$type": "Asi.Soa.Core.DataContracts.PagedResult`1[[Asi.Soa.Membership.DataContracts.CountryData, Asi.Contracts]], Asi.Contracts",
"Items": {
"$type": "System.Collections.Generic.List`1[[Asi.Soa.Membership.DataContracts.CountryData, Asi.Contracts]], mscorlib",
"$values": [
{
"$type": "Asi.Soa.Membership.DataContracts.CountryData, Asi.Contracts",
"CountryCode": "AD",
"CountryName": "Andorra",
"CountrySubEntities": {
"$type": "Asi.Soa.Membership.DataContracts.CountrySubEntityDataCollection, Asi.Contracts",
"$values": []
},
"MailGroup": "EU",
"SubEntityNameCaption": "County / region",
"IsActive": true
},
{
"$type": "Asi.Soa.Membership.DataContracts.CountryData, Asi.Contracts",
"CountryCode": "AE",
"CountryName": "United Arab Emirates",
"CountrySubEntities": {
"$type": "Asi.Soa.Membership.DataContracts.CountrySubEntityDataCollection, Asi.Contracts",
"$values": []
},
"MailGroup": "ASIA",
"SubEntityNameCaption": "County / region",
"IsActive": true
},
{
"$type": "Asi.Soa.Membership.DataContracts.CountryData, Asi.Contracts",
"CountryCode": "AF",
"CountryName": "Afghanistan",
"CountrySubEntities": {
"$type": "Asi.Soa.Membership.DataContracts.CountrySubEntityDataCollection, Asi.Contracts",
"$values": []
},
"MailGroup": "ASIA",
"SubEntityNameCaption": "County / region",
"IsActive": true
}
]
},
"Offset": 0,
"Limit": 3,
"Count": 3,
"TotalCount": 245,
"NextPageLink": null,
"HasNext": true,
"NextOffset": 3
}
To call the API we need something like:
JavaScriptlet requestVerificationToken = document.getElementById("RequestVerificationToken").value;
const options = {
method: 'GET',
headers: { 'Content-Type': 'application/json', "RequestVerificationToken": requestVerificationToken}};
fetch('[/api/Country?Limit=3'), options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.Error(err));
We are struggling to understand how to use the "Choice from RESTFul service" or "onLoadChoicesFromServer" to get the relevant Data especially when its not a flat and straight forward JSOn format. Can you please help us with some code example on how to achieve this with "onLoadChoicesFromServer"? Is there anything extra we need to do to handle those types of question in dynamic panels?
Thanks,
Ajay