Thank you in advance for your time and comments.
Question : I want to show or reflect the most recent status by showing only the latest HardwareStatus”offline” entries, unless they are followed by an “online” entry. If an “online” entry is created, it should remove the “offline” entry from the gallery.
Gallery 1 : (shows both Online and Offline entries from Sharepoint List)
Gallery 2 : (It should only show Offline for recent or last entry where there is no subsequent Online entry for same HName
To test if there is no delay issue, I have two buttons to test it –
Button 1: “ColHardwareStatus”
Button 2 : “colUniqueHardwareStatus”
Power Apps Strucutre :
CountRows(
Distinct(
Filter(
DataforCRMApp,
HardwareStatus = “Offline” &&
Text(Created,”dd/mm/yyyy”) = Text(Today(),”dd/mm/yyyy”)
),
HName
)
ClearCollect(
colUniqueHardwareStatus,
AddColumns(
GroupBy(
Filter(
colHardwareStatusToday,
HardwareStatus = “Offline” &&
IsEmpty(
Filter(
colHardwareStatusToday, // Ensure to reference the correct collection if changed above
HName = ThisRecord.HName,
HardwareStatus = “Online”,
Created > ThisRecord.Created
)
)
),
HName,
AllEntries
),
LatestStatus, First(SortByColumns(ThisRecord.AllEntries, “Created”, SortOrder.Descending)).HardwareStatus,
LatestDateTime, First(SortByColumns(ThisRecord.AllEntries, “Created”, SortOrder.Descending)).Created
)
);
Timer button added to automate –
// Collect all relevant entries for the day
ClearCollect(
colHardwareStatusToday,
SortByColumns(
Filter(
DataforCRMApp,
Text(Created, “dd/mm/yyyy”) = Text(Today(), “dd/mm/yyyy”) &&
HName Blank() && HName “”,
(HardwareStatus = “Offline” || HardwareStatus = “Online”)
),
“Created”,
SortOrder.Descending
)
);
// Trigger the second timer after collection is updated
//UpdateContext({StartSecondTimer: true});
ClearCollect(
colUniqueHardwareStatus,
AddColumns(
GroupBy(
Filter(
colHardwareStatusToday,
HardwareStatus = “Offline” &&
IsEmpty(
Filter(
colHardwareStatusToday, // Ensure to reference the correct collection if changed above
HName = ThisRecord.HName,
HardwareStatus = “Online”,
Created > ThisRecord.Created
)
)
),
HName,
AllEntries
),
LatestStatus, First(SortByColumns(ThisRecord.AllEntries, “Created”, SortOrder.Descending)).HardwareStatus,
LatestDateTime, First(SortByColumns(ThisRecord.AllEntries, “Created”, SortOrder.Descending)).Created
)
);