0

in PowerApps, I am trying to move tasks that are marked with a checkbox in the gallery to the last position. Currently, my project is structured as follows:

In the OnStart property of the app, I am creating a collection to add users who are divided into groups in my database:

App OnStart =

ClearCollect(
    colUserGroupStatus,
    AddColumns(
        UserGroupStatus,
        "UserEmailStr", UserEmail.Email,
        "GroupStr", GroupStatus.Value
    )
);

Next, in the taskList gallery's Items property, I filter to display tasks by user groups associated with the TB_FORM list using UserGroupStatus and the due date:

taskList Gallery Items = 

    Filter(
        TB_FORM,
        DueDate > Today() &&
        true in ForAll(
            LookUp(
                UserGroupStatus,
                UserEmail.Email = User().Email
            ).GroupStatus.Value,
            ThisRecord in Group.Value
        )
    )

In the Title property where tasks are displayed, I use a checkbox to strike through the text:

Title3 Strikethrough = 
//task is the name of the checkbox
task.Value

In my UserGroupStatus list where all users are stored, I add the task ID from TB_FORM that the user clicked on the checkbox via the OnCheck event. Each task ID that the user checks is separated by a comma:

task checkbox OnCheck = 
    
    Patch(
        UserGroupStatus,
        LookUp(UserGroupStatus, UserEmail.Email = User().Email),
        {
            TaskID: If(
                IsBlank(LookUp(UserGroupStatus, UserEmail.Email = User().Email).TaskID),
                Text(ThisItem.ID),
                LookUp(UserGroupStatus, UserEmail.Email = User().Email).TaskID & "," & Text(ThisItem.ID)
            )
        }
    );
    Refresh(TB_FORM);

In the OnUncheck event, the checkbox is unchecked, the text is unmarked, and the data is removed from SharePoint:

Patch(
        UserGroupStatus,
        LookUp(UserGroupStatus, UserEmail.Email = User().Email),
        {
            TaskID: Substitute(
                Substitute(
                    Substitute(
                        LookUp(UserGroupStatus, UserEmail.Email = User().Email).TaskID,
                        Text(ThisItem.ID),
                        ""
                    ),
                    ",,",
                    ","
                ),
                ",",
                ""
            )
        }
    );
    Refresh(TB_FORM);
    Refresh(UserGroupStatus);

The main question and difficulty I'm facing is how to sort these tasks and move the ones marked with a checkbox in the gallery to the last position. Currently, my project is structured in a way where multiple tasks can be associated with a user.

Now, let's take a look at the two lists I'm using for this in SharePoint:

TB_FORM List:

TB_FORM List:
ID: Number - Unique identifier for the task.
Title: Text - The title of the task.
DueDate: Date - The task's due date.
Modified: Date - The date when the task was last modified.
Created: Date - The date when the task was created.
Created By: User - The user who created the task.
Modified By: User - The user who last modified the task.
Group: Choice or Text - The group to which the task is assigned.
formUrl: Hyperlink - The URL of the form associated with the task.

UserGroupStatus List:

UserGroupStatus List:
ID: Number - Unique identifier for the record.
Nome: Text - The name of the collaborator.
Group: Single line of text - The employee's position or role.
UserEmail: User - The user's email.
GroupStatus: Choice or Text - The group to which the user belongs.

and a image bellow how it should work

Sajjad Ali
  • 91
  • 2
  • 10
  • Have you tried wrapping your Gallery.Items formula in a Sort() function? You can use boolean fields for this purpose. – mmikesy90 Jun 05 '23 at 12:26

0 Answers0