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

Assign only unique numbers to items using ForAll and Patch

One Gallery has a list of transactions and one collection has a list of unique numbers.

On select, I need to assign the unique numbers to each filtered transaction.  I managed it with the formula below.  (Thanks, Mr. Dang for your videos.)

 

However, when I added a new transaction in the same group and click the button, I need to assign the next unique number to the new transaction, but the first number in the collect was assigned.

 

Can you help me how to modify my formula to do the task?

Thanks in advance.

 

OnSelect=

ClearCollect(CasNumOption,Cashier_Num);
ForAll(Gallery1.AllItems,
    Patch(Reservation_Record,
        First(Filter(Reservation_Record,And(R_Date > DatePicker1.SelectedDate-1, R_Date < DatePicker1.SelectedDate + 1, Cashier_Num2 = 0))),
        {Cashier_Num2: Value(First(CasNumOption).Cashier_Num1)}
);
    Remove(CasNumOption,First(CasNumOption))
)

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Frequent Visitor

Actually, I found a solusion by myself.

FYI here:

 

I made another collction collecting the used Unique numbers, then removed duplicated numbers from the 1st collection with the used Unique numbers.

 

ClearCollect(CasNumUsed,ShowColumns(Filter(Reservation_Record,And(R_Date > DatePicker1.SelectedDate-1, R_Date < DatePicker1.SelectedDate + 1)),"Cashier_Num2"));
RemoveIf(CasNumOption,Cashier_Num1 exactin CasNumUsed.Cashier_Num2);

View solution in original post

1 REPLY 1
Highlighted
Frequent Visitor

Actually, I found a solusion by myself.

FYI here:

 

I made another collction collecting the used Unique numbers, then removed duplicated numbers from the 1st collection with the used Unique numbers.

 

ClearCollect(CasNumUsed,ShowColumns(Filter(Reservation_Record,And(R_Date > DatePicker1.SelectedDate-1, R_Date < DatePicker1.SelectedDate + 1)),"Cashier_Num2"));
RemoveIf(CasNumOption,Cashier_Num1 exactin CasNumUsed.Cashier_Num2);

View solution in original post

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 (7,243)