cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ramonjairo31
Helper II
Helper II

Move task up and down

I am developing a repeating table in PowerApps that contains a list of tasks (see image).
These tasks have a start date, number of days, and an end date. Creating the task table was not difficult, but, I have a requirement to move tasks up and down and I can't do that. because I need to recalculate date again in the new order given 


image.png

23 REPLIES 23

@Ramonjairo31 ,

That should have been your first post - it has taken 20 to get there. You have to help us help you.

You also need to understand your own code

SortByColumns(
   CollectionTask,
   "TaskOrder"
)

is doing exactly what you have asked it to do - sort by Task Order, so when the task order changes, so do the items. If you want the gallery sorted by a date (as I described) , then sort by the date column

SortByColumns(
   CollectionTask,
   "Start Date"
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Ramonjairo31
Helper II
Helper II

This is the solution

 

Button Up

UpdateContext({varChangeItemONESortNumber: ThisItem.TaskOrder});
UpdateContext({varChangeItemTWOSortNumber: ThisItem.TaskOrder - 1});
Patch(
    CollectionTask,
    ThisItem,
    {TaskOrder: varChangeItemTWOSortNumber}
);
Patch(
    CollectionTask,
    First(
        Filter(
            CollectionTask,
            TaskOrder = varChangeItemTWOSortNumber
        )
    ),
    {TaskOrder: varChangeItemONESortNumber}
)

 

Button Down

UpdateContext({varChangeItemONESortNumber: ThisItem.TaskOrder});
UpdateContext({varChangeItemTWOSortNumber: ThisItem.TaskOrder + 1});
Patch(
    CollectionTask,
    ThisItem,
    {TaskOrder: varChangeItemTWOSortNumber}
);
Patch(
    CollectionTask,
    First(
        Filter(
            CollectionTask,
            TaskOrder = varChangeItemTWOSortNumber
        )
    ),
    {TaskOrder: varChangeItemONESortNumber}
)

on the item property in the gallery 

SortByColumns(CollectionTask,"TaskOrder")

@Ramonjairo31 ,

You have marked your own post as the solution - please consider the time spent getting you there and the relevant post that assisted you.

@WarrenBelz 

 


I'm really feeling thankful for your help you have guided me until the end, however, I did mark my post as the solution because this will help others to get right to the point, but if you post what I did, I can mark yours as the solution.

 

Thank you very much,

 

I really appreciate it

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (2,715)