Issue displaying current user's name and profile photo on Home Page (Freedom UI)
Hi everyone,
I'm working on a Home Page in Creatio Studio using Freedom UI, where I want to display the currently logged-in user's name and profile picture. However, instead of the actual user's info, the system is consistently loading details (name and photo) of Marcus Morgan, which seems like a default or cached contact.
The other strange part is that none of the console logs are getting displayed which should mean that the Init is not firing either.
Is there a simpler way to achieve this task?
define("i8Page_d1nf084", ["@creatio-devkit/common"], function(DevKit) {
return {
viewConfigDiff: [
{
"operation": "insert",
"name": "ImageInput_ui1245i",
"values": {
"layoutConfig": {
"column": 9,
"row": 1,
"colSpan": 2,
"rowSpan": 2
},
"type": "crt.ImageInput",
"labelPosition": "auto",
"value": "$ContactDS_Photo_dc68cha",
"size": "large",
"borderRadius": "medium",
"positioning": "cover",
"visible": true,
"readonly": false,
"tooltip": ""
},
"parentName": "Main",
"propertyName": "items",
"index": 0
},
{
"operation": "insert",
"name": "Input_snebs28",
"values": {
"layoutConfig": {
"column": 9,
"row": 3,
"colSpan": 2,
"rowSpan": 1
},
"type": "crt.Input",
"multiline": false,
"label": "$Resources.Strings.ContactDS_Name_fyp4sby",
"labelPosition": "auto",
"control": "$ContactDS_Name_fyp4sby"
},
"parentName": "Main",
"propertyName": "items",
"index": 1
}
],
viewModelConfigDiff: [
{
"operation": "merge",
"path": ["attributes"],
"values": {
"ContactDS_Photo_dc68cha": {
"modelConfig": {
"path": "ContactDS.Photo"
}
},
"ContactDS_Name_fyp4sby": {
"modelConfig": {
"path": "ContactDS.Name"
}
}
}
}
],
modelConfigDiff: [
{
"operation": "merge",
"path": [],
"values": {
"dataSources": {
"ContactDS": {
"type": "crt.EntityDataSource",
"scope": "page",
"config": {
"entitySchemaName": "Contact"
}
}
},
"primaryDataSourceName": "ContactDS"
}
}
],
handlers: [
{
"lifecycles": ["init"],
"handler": async function(context) {
const { requestUserInfo, Filters, ComparisonType } = DevKit;
console.log("Initializing homepage");
const userInfo = await requestUserInfo();
console.log("User Info:", userInfo);
const contactId = userInfo.contactId;
console.log("Contact ID:", contactId);
const filter = new Filters.FilterGroup();
filter.addItem(
new Filters.ColumnFilter(ComparisonType.Equal, "Id", contactId)
);
console.log("Applying filter:", filter);
const result = await context.readData("ContactDS", {
filter: filter,
isClearGridData: true
});
console.log("Read result:", result);
if (result && result.success && result.records && result.records.length > 0) {
console.log("Setting property value with:", result.records[0]);
await context.setPropertyValue("ContactDS", result.records[0]);
} else {
console.warn("No matching contact found or read failed.");
}
}
}
],
converters: {},
validators: {}
};
});
Like