I am working with Freedom UI in Creatio and I need to populate a virtual lookup with data. I have defined the ViewModel attributes and configured the view, but when I try to populate the lookup with data using a handler for crt.HandleViewModelInitRequest
, the lookup does not display the data. I have used a custom array of data to populate the lookup, but it seems to be incorrect. Could you provide an example or guidance on how to correctly populate a virtual lookup with data in Creatio Freedom UI?
{
"operation": "insert",
"name": "VirtualSchemaLookup",
"values": {
"layoutConfig": {
"column": 1,
"row": 1,
"colSpan": 1,
"rowSpan": 1
},
"type": "crt.ComboBox",
"label": "Virtual Schema Lookup",
"labelPosition": "auto",
"control": "$VirtualSchemaLookup",
"listActions": [],
"showValueAsLink": true,
"controlActions": [],
"visible": true,
"readonly": false,
"placeholder": "",
"tooltip": "",
"valueDetails": null
},
"parentName": "GeneralInfoTabContainer",
"propertyName": "items",
"index": 0
},
viewModelConfigDiff:
"VirtualSchemaLookup": {
"dataValueType": Terrasoft.DataValueType.LOOKUP,
"isCollection": false,
"value": null
},
"VirtualSchemaLookupList": {
"dataValueType": Terrasoft.DataValueType.COLLECTION,
"isCollection": true,
"value": []
},
{
request: "crt.HandleViewModelInitRequest",
handler: async (context, next) => {
try {
var resultConfig = {
"1": {
value: "1",
displayValue: "Test Schema 1",
name: "TestSchema1"
},
"2": {
value: "2",
displayValue: "Test Schema 2",
name: "TestSchema2"
},
"3": {
value: "3",
displayValue: "Test Schema 3",
name: "TestSchema3"
}
};
if (context.$context.attributes && context.$context.attributes.VirtualSchemaLookupList ) {
context.$context.attributes.VirtualSchemaLookupList = resultConfig;
console.log(context.$context);
} else {
console.error("error");
}
await next?.handle(context);
} catch (error) {
console.error("Ошибка при инициализации модели:", error);
}
}
}
Despite filling the VirtualSchemaLookupList
attribute with data, the lookup does not display the data when the page is loaded
Could you provide an example or detailed guidance on how to correctly populate a virtual lookup with data in Creatio Freedom UI?
Thank you!