Need some help here, I only want to reset TextInputTicket if patch is successful. Currently it will reset even if Patch is not successful.
If(
TabListMenu.Selected.Value = "Message" && !IsBlank(TextInputTicket.Value),
Refresh(Helpdesk);
// Refresh the data source before Patch
Patch(
Helpdesk,
CurrentItem,// Use the context variable set in the Gallery
{
'Case Comments': "<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.'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: ""
}
}
);
// Check for errors during the patch operation
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),
Refresh(Helpdesk);
// Refresh the data source before Patch
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: ""
}
}
);
// Check for errors during the patch operation
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),
Refresh(Helpdesk);
// Refresh the data source before Patch
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: ""
}
}
);
// Check for errors during the patch operation
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,
"Created",
SortOrder.Descending
)
);
UpdateContext({itemSelected: false})
)
)