0

I have the following formula to get all the planner tasks:-

Collect(colRelatedPlannerTasks,
Planner.ListTasksV3(planner.id,group.Value).value);

now how i can dynamically filter those tasks based on the AssignedTo user and the Completion status? currently i am getting all the tasks and then filter them, but is there a more efficient way so we only get the needed filtered planner tasks?

Thanks

1 Answer 1

0

To dynamically filter Planner tasks based on the assigned user and completion status more efficiently, you should use the filtering capabilities of the Planner API directly within your formula. Unfortunately, the Planner API doesn't provide direct filtering options in the request itself like some other Microsoft Graph endpoints, but you can optimize the process by applying filters as soon as you collect the data.

Here's how you can modify your approach to filter the tasks based on AssignedTo and CompletionStatus right after collecting them:

  1. Collect the tasks using Planner.ListTasksV3:
    • Collect the tasks from Planner.
    • Filter the tasks dynamically based on AssignedTo and CompletionStatus.
// Collect all tasks first
ClearCollect(colAllPlannerTasks,
    Planner.ListTasksV3(planner.id, group.Value).value
);

// Filter the collected tasks based on AssignedTo and CompletionStatus
ClearCollect(colFilteredPlannerTasks,
    Filter(colAllPlannerTasks,
        AssignedToUserId = "user-id-here" && // Replace "user-id-here" with the ID of the assigned user
        PercentComplete = 100 // Use 100 for completed tasks and 0 for not started
    )
);

In this example:

  • AssignedToUserId: Replace "user-id-here" with the actual ID of the assigned user.
  • PercentComplete: This is used to determine the completion status (100 for completed, 0 for not started).

If you need to dynamically specify the AssignedTo user and CompletionStatus, you can use variables or controls in PowerApps to capture user input:

// Example with dynamic user input
ClearCollect(colFilteredPlannerTasks,
    Filter(colAllPlannerTasks,
        AssignedToUserId = DropdownAssignedUser.Selected.Value && // Assuming a dropdown for selecting user
        PercentComplete = SliderCompletionStatus.Value // Assuming a slider for completion status
    )
);

Notes:

  • Ensure the AssignedToUserId matches the actual field name from the tasks data.
  • PercentComplete typically ranges from 0 to 100 in Planner tasks, representing the percentage completion.

By using ClearCollect with Filter immediately after collecting the tasks, you ensure that only the relevant tasks are kept in colFilteredPlannerTasks, making your app more efficient and responsive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.