At first glance, it looks like your filter is quite long, which could possibly contribute to PowerApps's confusion when navigating.
If(IsBlank(TextSearchBox1_8.Text),
Sort(
If(type="New",
Filter(Tickets, Status="New"),
If(type="MyNew",
Filter(Tickets, Status="New" && TechEmail=currentUser_1.Text),
If(type="MyInprogress",
Filter(Tickets,
(TechEmail=currentUser_1.Text && Completed="No" && Status="In progress") ||
(TechEmail=currentUser_1.Text && Status="Awaiting Info") ||
(TechEmail=currentUser_1.Text && Status="Info Received")),
If(type="Cancelled",
Filter(Tickets, Status="Cancelled"),
If(type="Received",
Filter(Tickets,Status="Info Received" && Completed="No" && TechEmail=currentUser_1.Text),
If(type="All",
Filter(Tickets,Completed="No" ),
If(type="MyAll",
Filter(Tickets,Completed="No" && TechEmail=currentUser_1.Text),
If(type="In progress",
Filter(Tickets,
(Status="In progress" && Completed="No") ||
(Status="Info Received" && Completed="No") ||
(Status="Awaiting Info" && Completed="No")),
If(type="On hold",
Filter(Tickets,Status="On hold" && Completed="No"),
If(type="MyOnhold",
Filter(Tickets,Status="On hold" && Completed="No" && TechEmail=currentUser_1.Text),
If(type="Closed",
Filter(Tickets,Status="Closed"),
If(type="LEARN HH",
Filter(Tickets,Location="LEARN HH" && Completed="No"),
If(type="SSS",
Filter(Tickets,Location="SSS" && Completed="No"),
If(type="TRMC",
Filter(Tickets,Location="TRMC" && Completed="No"),
If(type="DLAMMS",
Filter(Tickets,Location="DLAMMS" && Completed="No"),
If(type="CTRA",
Filter(Tickets,Location="CTRA" && Completed="No"),
If(type="TFS",
Filter(Tickets,Location="TFS" && Completed="No"),
If(type="MSMHS",
Filter(Tickets,Location="MSMHS" && Completed="No"),
If(type="RMMS",
Filter(Tickets,Location="RMMS" && Completed="No"),
If(type="AllLocation",
Filter(Tickets,Location="ALL Location" && Completed="No"),
If(type="3daysOld",
Filter(Tickets,
Completed="No",
DateCreated <> datetype && DateCreated <>Text(Today()),
DateCreated <> Text(DateAdd(Today(), -2)),
DateCreated <> Text(DateAdd(Today(), -1)
))))))))))))))))))))))),
Modified,Descending)
,
SortByColumns(
Search(Tickets, TextSearchBox1_8.Text, "Comment","Status","AssignedTo","RequestID","ServiceTypes","Location","Title","Subject","Description"),
"Modified",Descending)
)
I'm guessing you have a textbox or a dropdown that the user can change, thus, assigning the value of type, and defining the type of filter to use on your gallery.
If it were up to me (and it is not), I would create separate dropdowns for the filtered columns (e.g. Location, Completed, DateCreated, etc.) and then they could be individually used to filter the gallery; however, I understand that people cater their design to the form and shape that makes the most sense to them. So, if you want to do a templated view type, here is one way to approach this:
- Make a note of the columns in your dataSource (Tickets) that you are filtering. These just happen to be in no particular order:
- Status
- TechEmail
- Location
- Completed
- DateStart
- DateEnd
- Since you are using your predefined templates (e.g. "New", "MyNew", etc.), then we need to make a note of that as well.
- Create a collection based on this information in the Screen.OnVisible:
ClearcCollect(myFilters,
Table(
{
TemplateName: "New",
FilterStatus: "New",
FilterTechEmail: Blank(),
FilterDateStart: Blank(),
FilterDateEnd: Blank(),
FilterCompleted: "No",
FilterLocation: Blank(),
ListOrder: 1
},
{
TemplateName: "MyNew",
FilterStatus: "New",
FilterTechEmail: currentUser_1.Text,
FilterDateStart: Blank(),
FilterDateEnd: Blank(),
FilterCompleted: "No",
FilterLocation: Blank(),
ListOrder: 2
},
etc...
{
TemplateName: "3daysOld",
FilterStatus: Blank(),
FilterTechEmail: Blank(),
FilterDateStart: Today() - 3,
FilterDateEnd: Blank(),
FilterCompleted: No,
FilterLocation: Blank(),
ListOrder: 20
}
)
) - The net result is that you will have a collection--in in-memory table--with the values that you will eventually filter your gallery with.
- Create a dropDown control. We leverage the ListOrder field in the new collection to put these items in the order you desire. Let's call this DropDown1. Set it's items accordingly (making sure to set its DisplayFields in the Advanced settings to ["TemplateName"]):
DropDown1.Items =
SortByColumn(myFilters,
ListOrder, Ascending
)
- Now you have a dropdown that shows your template filters. It's time to give your gallery filter a facelift:
Search(TextSearchBox1_8.Text,
Filter(Tickets,
If(IsBlank(DropDown1.Selected.Status),
true,
Status = DropDown1.Selected.FilterStatus
),
If(IsBlank(DropDown1.Selected.FilterTechEmail),
true,
TechEmail = DropDown1.Selected.FilterTechEmail
),
etc. with the other filters...
),
"Comment", "Status", "AssignedTo", "RequestID", "ServiceTypes", "Location", "Title", "Subject", Description"
)
- This will trim your If-Statements down from 21 statements down to 6. Plus, if you ever create new templates in the future, you just update your collection table (step 3) and you will remain at 6 If-Statements. In fact, you no longer have to touch your gallery filters (unless you want to add new columns to filter).
As far as your navigation:
Object.OnSelect =
Navigate(TicketdetailsPage,
ScreenTransition.None,
{PsFeatures:false,TSelected:ThisItem.ID,TAssetID:ThisItem.AssetID}
)There's nothing wrong with using variables (e.g. PsFeatures, TSelected, TAssetID, etc.). In PowerApps, variables are finnicky. That's because PowerApps doesn't always do everything in chronological order. It's sort of like telling a bunch of 5th graders how to clean up the classroom and telling them to execute. The guys who are supposed to clean up on step2 might goof up and take longer than intended; the guys in step3 might finish before. When you take a snapshot, especially with a bunch of if-statements and data loading here-and-there, the result is finnicky at best. You're better off referring to an absolute value.
The values and properties of your gallery (let's call it Gallery1) are absolute. The good news is that they're also universal, meaning you can refer to its values and properties from any screen. Let's say your tickets have a column called Details. And TicketdetailsPage has a textbox called textDetails and another called textAssetID. You would just have to do this:
textDetails.text =
gallery1.Selected.Details
textAssetID.text =
gallery1.Selected.AssetID
Even if this doesn't solve your problems, I hope it gives you a different perspective of simplifying and troubleshooting the solution.