Hi all,
I have a series of buttons within a gallery, this gallery's items is based on the selected item from the gallery before.
I can press the buttons and my functions work as planned with no problems
I have just added an 'update if ' to the end of my code for a certain button, it works as planned but after pressing my gallery items disappear, the labels on screen which show which item is selected prove that it isn't recognizing the previous selected item.
I don't have a refresh built in or anything.
Some images attached , 2nd image is after pressing Stop - the other 3 buttons don't cause this to happen.First screen
2nd screen
All buttons showing
And finally, code of the troublesome stop button, apologies for the length of it, sure it could be done better, but as I say, was working fine up until the now Italic and underlined section.
Patch(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
),
{Title: Gallery13.Selected.Title},
{
Title: Gallery13.Selected.Title,
Stop: Now(),
Elapsed: DateDiff(
LookUp(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
),
Title = Gallery13.Selected.Title,
Start
),
Now(),
Minutes
),
TotalPauseTime: Sum(
Filter(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
),
Title = ThisItem.Title
),
PauseTime
)
}
);
Patch(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
),
{Title: Gallery13.Selected.Title},
{
Title: Gallery13.Selected.Title,
ActWorkingTime: Sum(
Last(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
)
).Elapsed - Last(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
)
).TotalPauseTime
),
NumberOfBreaks: Sum(
CountIf(
Filter(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
),
Title = ThisItem.Title
),
!IsBlank(Unpause)
)
),
Status: "OpComplete",
Start: LookUp(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
),
Title = Gallery13.Selected.Title,
Start
),
Stop: LookUp(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
),
Gallery13.Selected.Title = Title && !IsBlank(Stop),
Stop
),
Elapsed: DateDiff(
LookUp(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
),
Gallery13.Selected.Title = Title,
Start
),
Now(),
Minutes
),
TotalPauseTime: Sum(
Filter(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
),
Title = ThisItem.Title
),
PauseTime
)
}
);
If(
ThisItem.Operation = "Cutting",
UpdateIf(
'Steel Jobs',
JobNumber = Gallery13.Selected.Title,
{
ActCuttingTime: Sum(
Last(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
)
).Elapsed - Last(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
)
).TotalPauseTime
)
}
),
ThisItem.Operation = "Drilling",
UpdateIf(
'Steel Jobs',
JobNumber = Gallery13.Selected.Title,
{
ActDrillingTime: Sum(
Last(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
)
).Elapsed - Last(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
)
).TotalPauseTime
)
}
),
ThisItem.Operation = "Welding",
UpdateIf(
'Steel Jobs',
JobNumber = Gallery13.Selected.Title,
{
ActWeldingTime: Sum(
Last(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
)
).Elapsed - Last(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
)
).TotalPauseTime
/60)
}
),
ThisItem.Operation = "Inspection",
UpdateIf(
'Steel Jobs',
JobNumber = Gallery13.Selected.Title,
{
ActInspectionTime: Sum(
Last(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
)
).Elapsed - Last(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
)
).TotalPauseTime
)
}
),
ThisItem.Operation = "Assembly",
UpdateIf(
'Steel Jobs',
JobNumber = Gallery13.Selected.Title,
{
ActAssemblyTime: Sum(
Last(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
)
).Elapsed - Last(
If(
ThisItem.Operation = "Cutting",
TempCuttingTimeLog,
ThisItem.Operation = "Drilling",
TempDrillingTimeLog,
ThisItem.Operation = "Welding",
TempWeldingTimeLog,
ThisItem.Operation = "Inspection",
TempInspectionTimeLog,
ThisItem.Operation = "Assembly",
TempAssemblyTimeLog
)
).TotalPauseTime
)
}
)
)
Solved! Go to Solution.
Best way to solve this is to reference a variable instead. When the user clicks on the Gallery1 run this code using the OnSelect property.
Set(varGalleryRecord, ThisItem)
Then change any references to Gallery1.Selected.Value to varGalleryRecord instead.
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
Best way to solve this is to reference a variable instead. When the user clicks on the Gallery1 run this code using the OnSelect property.
Set(varGalleryRecord, ThisItem)
Then change any references to Gallery1.Selected.Value to varGalleryRecord instead.
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
Thanks, @mdevaney , I've changed all references and it is still happening, sometimes it works fine, others it loses the item.
I've double checked I haven't missed any references using Word too.
May have to add a navigate back to first screen on the end, not ideal but will cover up the issue.
Without changing anything from my last post, it does now seem to be working, thank you @mdevaney
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
199 | |
72 | |
50 | |
41 | |
30 |
User | Count |
---|---|
253 | |
113 | |
95 | |
91 | |
76 |