If(
TabListMenu.Selected.Value = "Message" && !IsBlank(TextInputTicket.Value),
Patch(
Helpdesk,
CurrentItem, // Use the context variable set in the Gallery
{
'Case Comments': "<b>" & Char(10) & User().FullName & "</b>" & "<br> <span style='font-size:10.5pt'>" & Text(
Now(),
"[$-en-US]yyyy/mm/dd hh:mm"
) & "</span> <br> " & TextInputTicket.Value & CurrentItem.'Case Comments',
LastComment: TextInputTicket.Value,
'Last Modified By': {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Department: "",
DisplayName: User().FullName,
Claims: "i:0#.f|membership|" & Lower(User().Email),
Email: User().Email,
JobTitle: "",
Picture: ""
},
'Last Comment Made By': {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Department: "",
DisplayName: User().FullName,
Claims: "i:0#.f|membership|" & Lower(User().Email),
Email: User().Email,
JobTitle: "",
Picture: ""
}
}
);
If(
!IsEmpty(Errors(Helpdesk)),
// Errors occurred, handle them and do not reset TextInputTicket
Notify(
First(Errors(Helpdesk)).Message,
NotificationType.Error
),
// No errors, proceed with additional actions
UpdateContext(
{
CurrentItem: LookUp(
Helpdesk,
ID = CurrentItem.ID
)
}
);
Reset(TextInputTicket)
)
);
If(
TabListMenu.Selected.Value = "Worklog" && !IsBlank(TextInputTicket.Value),
Patch(
Helpdesk,
CurrentItem, // Use the context variable set in the Gallery
{
Worklog: "<b>" & Char(13) & Char(13) & User().FullName & "</b>" & "<br> <span style='font-size:10.5pt'>" & Text(
Now(),
"[$-en-US]yyyy/mm/dd hh:mm"
) & "</span> <br> " & Char(13) & TextInputTicket.Value & CurrentItem.Worklog,
'Last Modified By': {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Department: "",
DisplayName: User().FullName,
Claims: "i:0#.f|membership|" & Lower(User().Email),
Email: User().Email,
JobTitle: "",
Picture: ""
}
}
);
If(
!IsEmpty(Errors(Helpdesk)),
// Errors occurred, handle them and do not reset TextInputTicket
Notify(
First(Errors(Helpdesk)).Message,
NotificationType.Error
),
// No errors, proceed with additional actions
UpdateContext(
{
CurrentItem: LookUp(
Helpdesk,
ID = CurrentItem.ID
)
}
);
Reset(TextInputTicket)
)
);
If(
TabListMenu.Selected.Value = "Close" && !IsBlank(TextInputTicket.Value),
Patch(
Helpdesk,
CurrentItem, // Use the context variable set in the Gallery
{
Resolution: "<b>" & Char(13) & Char(13) & User().FullName & "</b>" & "<br> <span style='font-size:10.5pt'>" & Text(
Now(),
"[$-en-US]yyyy/mm/dd hh:mm"
) & "</span> <br> " & Char(13) & TextInputTicket.Value & CurrentItem.Resolution,
'Last Modified By': {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Department: "",
DisplayName: User().FullName,
Claims: "i:0#.f|membership|" & Lower(User().Email),
Email: User().Email,
JobTitle: "",
Picture: ""
},
Status: {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id: 4,
Value: "Closed"
}
},
{
'Assigned To': {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims: "i:0#.f|membership|" & Lower(User().Email),
Department: "",
DisplayName: User().FullName,
Email: User().Email,
JobTitle: "",
Picture: ""
}
}
);
If(
!IsEmpty(Errors(Helpdesk)),
// Errors occurred, handle them and do not reset TextInputTicket
Notify(
First(Errors(Helpdesk)).Message,
NotificationType.Error
),
// No errors, proceed with additional actions
UpdateContext(
{
CurrentItem: LookUp(
Helpdesk,
ID = CurrentItem.ID
)
}
);
Reset(TextInputTicket)
)
);
If(
TabListMenu.Selected.Value = "Close",
// Additional logic for filtering TicketsCollection based on TabList1.Selected.Value
If(
TabList1.Selected.Value = "Unassigned",
ClearCollect(
TicketsCollection,
Filter(
Helpdesk,
Status.Value = "Unassigned"
)
);
UpdateContext({itemSelected: false})
);
If(
TabList1.Selected.Value = "My Tickets",
ClearCollect(
TicketsCollection,
Filter(
Helpdesk,
('Assigned To'.DisplayName = User().FullName) && ((Status.Value = "Assigned") || (Status.Value = "In Progress") || (Status.Value = "Waiting for user response") || (Status.Value = "Waiting for external resource") || (Status.Value = "Backlog"))
)
);
UpdateContext({itemSelected: false})
);
If(
TabList1.Selected.Value = "Closed",
ClearCollect(
TicketsCollection,
Filter(
Sort(
Helpdesk,
ID,
SortOrder.Descending
),
'Assigned To'.DisplayName = User().FullName && Status.Value = "Closed"
)
);
UpdateContext({itemSelected: false});
Notify(
"Ticket was closed and placed under Closed tickets.",
NotificationType.Success,
600
)
);
If(
TabList1.Selected.Value = "All",
ClearCollect(
TicketsCollection,
SortByColumns(
Helpdesk,
"CreatedDate",
SortOrder.Descending
)
);
UpdateContext({itemSelected: false})
)
)
// Define user details and timestamp once
Set(
currentUser,
{
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Department: "",
DisplayName: User().FullName,
Claims: "i:0#.f|membership|" & Lower(User().Email),
Email: User().Email,
JobTitle: "",
Picture: ""
}
);
Set(
timestamp,
"<b>" & Char(10) & User().FullName & "</b>" & "<br> <span style='font-size:10.5pt'>" & Text(Now(), "[$-en-US]yyyy/mm/dd hh:mm") & "</span> <br> "
);
// Handle Patch Operations
If(
!IsBlank(TextInputTicket.Value),
Switch(
TabListMenu.Selected.Value,
"Message",
Patch(
Helpdesk,
CurrentItem,
{
'Case Comments': timestamp & TextInputTicket.Value & CurrentItem.'Case Comments',
LastComment: TextInputTicket.Value,
'Last Modified By': currentUser,
'Last Comment Made By': currentUser
}
),
"Worklog",
Patch(
Helpdesk,
CurrentItem,
{
Worklog: timestamp & TextInputTicket.Value & CurrentItem.Worklog,
'Last Modified By': currentUser
}
),
"Close",
Patch(
Helpdesk,
CurrentItem,
{
Resolution: timestamp & TextInputTicket.Value & CurrentItem.Resolution,
'Last Modified By': currentUser,
Status: {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id: 4,
Value: "Closed"
},
'Assigned To': currentUser
}
)
);
// Handle Errors and Reset
If(
!IsEmpty(Errors(Helpdesk)),
Notify(First(Errors(Helpdesk)).Message, NotificationType.Error),
UpdateContext({ CurrentItem: LookUp(Helpdesk, ID = CurrentItem.ID) });
Reset(TextInputTicket)
)
);
// Handle Ticket Filtering based on Tab Selection
If(
TabListMenu.Selected.Value = "Close",
Switch(
TabList1.Selected.Value,
"Unassigned",
ClearCollect(TicketsCollection, Filter(Helpdesk, Status.Value = "Unassigned")),
"My Tickets",
ClearCollect(
TicketsCollection,
Filter(
Helpdesk,
('Assigned To'.DisplayName = User().FullName) && (Status.Value in ["Assigned", "In Progress", "Waiting for user response", "Waiting for external resource", "Backlog"])
)
),
"Closed",
ClearCollect(
TicketsCollection,
Filter(
Sort(Helpdesk, ID, SortOrder.Descending),
'Assigned To'.DisplayName = User().FullName && Status.Value = "Closed"
)
);
Notify("Ticket was closed and placed under Closed tickets.", NotificationType.Success, 600),
"All",
ClearCollect(TicketsCollection, SortByColumns(Helpdesk, "CreatedDate", SortOrder.Descending))
);
UpdateContext({ itemSelected: false })
)
WarrenBelz
146,524
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,906
Most Valuable Professional