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
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,959)