cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

powerapps

Hi Everyone,

 

There are n items in the gallery. I would like to prevent the 2nd order of the work order. I have 2 work orders 1 without finishing the work order 2. I want to do his job according to the order to start the work order. I wonder how I do that.

 

Related Picture Below

 

Thank You Now for Your Answer

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

OK, if I understand, what you're saying is that you don't want action to be able to be taken on the second item in the Gallery before the first one is completed. If that is correct, then the following solution will work. You will just have to change the logical tests to match your fields.

For my example, I have a datasource (myList) with an order field (theOrder), a field for if the work is completed (isComplete).

In the arrow icon of your Gallery, edit the DisplayMode property to put a test of the completed items. For my mockup, that amounted to:

If( 
First(
SortByColumns(
Filter(myList, isComplete = false),
"theOrder",
Ascending
)
).theOrder < ThisItem.theOrder,
DisplayMode.Disabled,
DisplayMode.Edit
)

So, what are we doing? I find it helpful to start at the inside and work out.

 

Filter() -- gets the return of records that are not marked as completed

SortByColumns() -- puts those records in an ascending order, so that the one we want to require to be the first one worked on is, in fact, the first in the returned set

First() -- gets that first record that should be worked on (the first one not marked as complete)

First().theOrder -- gets us the data in the sorting field so that we can compare it against our records. Only if ThisItem's sort field is equal to or less than will the DisplayMode of the button be "Edit." Put another way, if the sorted field is greater than the record that they SHOULD be working on, they WON'T be able to work on it, because the button will be disabled.

 

CAVEAT:

The result of this is that ANY work order at or below the current work order's sort value will have a button available. So when the user should be working on the first work order, that will be the only one with a visible/enabled button. When the first work order is marked as "completed" and the user can move on to the second work order, BOTH the first and the second work order will have the arrow icons. If you would prefer that the user is only allowed to work on the current work order (and not revisit previous work orders marked as Completed), change the less-than operator to an equals operator, and reverse the Disabled/Edit portions of the If() statement.

 

In that case, you should consider a way to let the user edit a previously completed work order to correct some mistake (if that is allowed by whatever other governance guiding your development). For example, you could alter the color of the arrow icon based on whether the work order was marked as "completed" or not.

If(ThisItem.isComplete, orange, black)

That way, only the latest work order to become available to the user would have an arrow of one color, while all other arrows for the completed work orders would be of a different color. If the process would be different for editing a completed item versus editing an in-process item, you'd add an If() statement in the OnSelect event of the arrow icon.

 

View solution in original post

5 REPLIES 5
Highlighted
Solution Sage
Solution Sage

Can you clarify some of the details of your project?

Do you mean you have 2 classifications of Work Orders? Or do you have sub-Work Orders related to a larger work order?

What is the specific behavior you want to limit, and what is the specific set of circumstances in which you want to limit the behavior? In the case where you encounter that circumstance, what behavior do you want instead? What behavior do you want if the circumstance is NOT met?

When you speak of doing this job "according to the order to start the work order," that sounds like a Sorting requirement. What would you be sorting on?

 

More information will help us help you.

Highlighted

There can be more than 2 work orders. no sub order.
I want to make business orders in order. 1. Do not start 2nd or 3rd job order without

Highlighted
Anonymous
Not applicable

Thank you for creating this thread @cagdas 

 

@TimRohr could you review the latest reply and advise if you can assist?

 

@Anonymous

Highlighted

OK, if I understand, what you're saying is that you don't want action to be able to be taken on the second item in the Gallery before the first one is completed. If that is correct, then the following solution will work. You will just have to change the logical tests to match your fields.

For my example, I have a datasource (myList) with an order field (theOrder), a field for if the work is completed (isComplete).

In the arrow icon of your Gallery, edit the DisplayMode property to put a test of the completed items. For my mockup, that amounted to:

If( 
First(
SortByColumns(
Filter(myList, isComplete = false),
"theOrder",
Ascending
)
).theOrder < ThisItem.theOrder,
DisplayMode.Disabled,
DisplayMode.Edit
)

So, what are we doing? I find it helpful to start at the inside and work out.

 

Filter() -- gets the return of records that are not marked as completed

SortByColumns() -- puts those records in an ascending order, so that the one we want to require to be the first one worked on is, in fact, the first in the returned set

First() -- gets that first record that should be worked on (the first one not marked as complete)

First().theOrder -- gets us the data in the sorting field so that we can compare it against our records. Only if ThisItem's sort field is equal to or less than will the DisplayMode of the button be "Edit." Put another way, if the sorted field is greater than the record that they SHOULD be working on, they WON'T be able to work on it, because the button will be disabled.

 

CAVEAT:

The result of this is that ANY work order at or below the current work order's sort value will have a button available. So when the user should be working on the first work order, that will be the only one with a visible/enabled button. When the first work order is marked as "completed" and the user can move on to the second work order, BOTH the first and the second work order will have the arrow icons. If you would prefer that the user is only allowed to work on the current work order (and not revisit previous work orders marked as Completed), change the less-than operator to an equals operator, and reverse the Disabled/Edit portions of the If() statement.

 

In that case, you should consider a way to let the user edit a previously completed work order to correct some mistake (if that is allowed by whatever other governance guiding your development). For example, you could alter the color of the arrow icon based on whether the work order was marked as "completed" or not.

If(ThisItem.isComplete, orange, black)

That way, only the latest work order to become available to the user would have an arrow of one color, while all other arrows for the completed work orders would be of a different color. If the process would be different for editing a completed item versus editing an in-process item, you'd add an If() statement in the OnSelect event of the arrow icon.

 

View solution in original post

Highlighted

I should be clear... changing the color of the arrow icon won't matter if you are ONLY showing the arrow for the one work order they should be working on (that is, going with the "=" in the formula so you only get one icon button in the Gallery).

 

My suggestion is to NOT go with the "=" if you need to be able to allow editing previously completed work orders. Instead, change the color and fiddle with the OnSelect event to control the apps behavior.

 

(Because the other option, using the "=" operator but also needing to allow edits, would be adding another control that would become visible/enabled only when an item was marked "completed," and which would have its own OnSelect event... and that just gets cumbersome for editing later.)

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

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