This documentation provides comprehensive guidance for reading ClientDTO.Extensions.Field.Answer data from the AlayaCare Residential API. The Extensions property contains dynamic form field data with various answer formats based on field types and subtypes.
"extensions": [
{
"formFieldLinkID": 288,
"fieldName": "Boolean-FF",
"recordState": 1,
"field": {
"type": 300,
"subType": 600,
"hasAnswer": true,
"answer": true,
"answerAsString": "Yes"
}
},
{
"formFieldLinkID": 305,
"fieldName": "StringWithExpiry-FF",
"recordState": 1,
"field": {
"type": 101,
"subType": 100,
"hasAnswer": true,
"answer": {
"value": "License123",
"expiryYear": 2025,
"expiryMonth": 8,
"summary": "License123. Expiry: 8/2025"
},
"answerAsString": "License123. Expiry: 8/2025"
}
}...
]
Use this approach when you know the specific field name you're looking for.
// Step 1: Get extensions
const extensions = client.extensions;
// Step 2: Find by field name
const extension = extensions.find(ext => ext.fieldName === "Boolean-FF");
// Step 3: Extract answer
if (extension && extension.field && extension.field.hasAnswer) {
const answer = extension.field.answer;
const displayText = extension.field.answerAsString;
}
function getAnswerByFieldName(client, fieldName) {
// Step 1: Get extensions
const extensions = client.extensions;
// Step 2: Find by field name
const extension = extensions.find(ext => ext.fieldName === fieldName);
// Step 3: Extract answer
if (extension && extension.field && extension.field.hasAnswer) {
return {
answer: extension.field.answer,
displayText: extension.field.answerAsString
};
}
return null;
}
// Usage
const result = getAnswerByFieldName(client, "String-FF");
console.log(result.answer); // "Sample text value"
Use this approach when you need to process all extensions without knowing specific field names.
// Step 1: Access client extensions
const extensions = client.extensions;
// Step 2 & 3: Process by type and subtype
extensions.forEach(extension => {
if (extension.field && extension.field.hasAnswer) {
const fieldType = extension.field.type;
const fieldSubType = extension.field.subType;
const answer = getAnswerByType(extension.field);
}
});
| Type | SubType | Field Type | Answer Property | Data Type |
|---|---|---|---|---|
| 100 | 100 | Text Box | answer | string |
| 100 | 101 | Text Area | answer | string |
| 101 | 100 | String with Expiry | answer | object |
| 200 | 200 | Numeric | answer | number |
| 201 | 200 | Numeric Range | answer | object |
| 300 | 600 | Boolean | answer | boolean |
| 400 | 400 | Date | answer | string |
| 400 | 402 | DateTime | answer | string |
| 400 | 403 | Time | answer | string |
| 401 | 400 | Date Range | answer | object |
| 401 | 402 | DateTime Range | answer | object |
| 401 | 403 | Time Range | answer | object |
| 500 | 500 | Choice Dropdown | answer | object |
| 500 | 501 | Radio Button | answer | object |
| 600 | 500 | Multiple Dropdown | answers | array |
| 600 | 600 | Checkboxes | answers | array |
Answer Format: Direct string value
{
"type": 100,
"subType": 100,
"answer": "Kevin Kumar",
"answerAsString": "Kevin Kumar"
}
field.answer returns stringAnswer Format: Direct string value
{
"type": 100,
"subType": 101,
"answer": "this is a text area demo",
"answerAsString": "this is a text area demo"
}
field.answer returns stringAnswer Format: Object with value, expiry month, and year
{
"type": 101,
"subType": 100,
"answer": {
"value": "License123",
"expiryYear": 2025,
"expiryMonth": 8,
"summary": "License123. Expiry: 8/2025"
},
"answerAsString": "License123. Expiry: 8/2025"
}
field.answer.value, field.answer.expiryMonth, field.answer.expiryYear, field.answer.summaryAnswer Format: Numeric value
{
"type": 200,
"subType": 200,
"answer": 5,
"answerAsString": "5"
}
field.answer returns numberAnswer Format: Object with start and stop values
{
"type": 201,
"subType": 200,
"answer": {
"start": 2,
"stop": 3
},
"answerAsString": "2 - 3"
}
field.answer.start, field.answer.stopAnswer Format: Boolean value
{
"type": 300,
"subType": 600,
"answer": true,
"answerAsString": "Yes",
"checkedValue": "Yes",
"uncheckedValue": "No"
}
field.answer returns booleanAnswer Format: ISO date string
{
"type": 400,
"subType": 400,
"answer": "2025-07-25T00:00:00",
"answerAsString": "2025-07-25"
}
field.answer returns ISO date stringAnswer Format: ISO datetime string
{
"type": 400,
"subType": 402,
"answer": "2025-07-22T18:00:00",
"answerAsString": "2025-07-22T18:00:00"
}
Answer Format: ISO time string
{
"type": 400,
"subType": 403,
"answer": "0001-01-01T13:30:00",
"answerAsString": "13:30:00"
}
field.answer returns ISO time stringAnswer Format: Object with start and stop date strings
{
"type": 401,
"subType": 400,
"answer": {
"start": "2025-07-20T00:00:00",
"stop": "2025-07-25T00:00:00"
},
"answerAsString": "20/07/2025 12:00:00 AM - 25/07/2025 12:00:00 AM"
}
field.answer.start, field.answer.stop{
"type": 401,
"subType": 402,
"answer": {
"start": "2025-07-15T16:00:00",
"stop": "2025-07-17T18:00:00"
},
"answerAsString": "15/07/2025 4:00:00 PM - 17/07/2025 6:00:00 PM"
}
{
"type": 401,
"subType": 403,
"answer": {
"start": "2025-07-21T09:00:00",
"stop": "2025-07-21T09:30:00"
},
"answerAsString": "21/07/2025 9:00:00 AM - 21/07/2025 9:30:00 AM"
}
Answer Format: Object with key (k) and value (v)
{
"type": 500,
"subType": 500,
"answer": {
"k": 564,
"v": "Business"
},
"answerAsString": "Business"
}
field.answer.k, field.answer.v{
"type": 500,
"subType": 501,
"answer": {
"k": 455,
"v": "choice 1"
},
"answerAsString": "choice 1"
}
answers property instead of answer
Answer Format: Array of objects with key (k) and value (v)
{
"type": 600,
"subType": 500,
"answers": [
{"k": 461, "v": "choice 1"},
{"k": 462, "v": "Is Vegan"}
],
"answerAsString": "choice 1, Is Vegan"
}
field.answers (array of objects){
"type": 600,
"subType": 600,
"answers": [
{"k": 458, "v": "choice 11"},
{"k": 459, "v": "choice 111"}
],
"answerAsString": "choice 11, choice 111"
}
function processExtensionsByType(client) {
// Step 1: Get extensions
const extensions = client.extensions;
const results = {};
extensions.forEach(extension => {
if (extension.field && extension.field.hasAnswer) {
// Step 2: Check type and subtype
const type = extension.field.type;
const subType = extension.field.subType;
// Step 3: Get answer based on type
let answer;
switch (type) {
case 100: // String
case 200: // Numeric
case 300: // Boolean
case 400: // Date/Time
answer = extension.field.answer;
break;
case 101: // String with Expiry
case 201: // Numeric Range
case 401: // Date/Time Range
case 500: // Single Choice
answer = extension.field.answer; // Object
break;
case 600: // Multiple Choice
answer = extension.field.answers; // Array
break;
default:
answer = extension.field.answer;
}
results[extension.fieldName] = {
answer: answer,
displayText: extension.field.answerAsString,
type: type,
subType: subType
};
}
});
return results;
}
hasAnswer before accessing valuesanswers array, not answeranswerAsString for user-friendly display texthasAnswer before accessing answer valuesanswerAsString for display purposes