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

Scan ID and update one record for that ID

Hi,

 

I am working on an app to check in and out employees by only scaning their barcode.

I have a simple sharepointlist with all employees with their unique number=barcode.

I use a statusfield with status = Yes or No to identify if the employee is present or away.

 

By scanning the barcode, a timer starts with 4 seconds the status should be changed from yes to no or from no to yes without a submit button

 

How should I write the patch to scan and update the record?

So far I have:

 

Patch(aanwezigheidMedewerkers;
LookUp(aanwezigheidMedewerkers;'medewerker number'=BarcodeScanner1_1.Value);
{status: No}
)

 

(yes I know I have to add an ifstatement to check if current status is yes or no but first I want to make it work for yes to no change.)

 

Can someone help me out?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @ejdregmans ,

Do you want to update an existing record in your SP List via scanning the unique barcode for each employee?

 

Actually, I think it is not necessary to add a Timer control to achieve your needs. I think the OnScan property of the BarcodeScanner control could achieve your needs.

Please set the OnScan property of the BarcodeScanner control to following:

Patch(
      aanwezigheidMedewerkers;
      LookUp(aanwezigheidMedewerkers;'medewerker number'=BarcodeScanner1_1.Value);
      {
        status: If(
                   LookUp(aanwezigheidMedewerkers;'medewerker number'=BarcodeScanner1_1.Value).status = true,
                   false,
                   true
                )
      }
)

Note: When assigning value to Yes/No type column in SP List, you need to use true or false Boolean value

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
mdevaney
Super User
Super User

@ejdregmans 

Set(currentRecord, LookUp(aanwezigheidMedewerkers;'medewerker number'=BarcodeScanner1_1.Value));
Patch(
    aanwezigheidMedewerkers;
    currentRecord;
    {
        status: Switch(currentRecord,
                       Yes, No,
                       No, Yes
                )
    }
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Thanks     @mdevaney  but I am struggling to get your code working.

 

I get several errors and could not resolve it myself. Could you please have a look and test it? I am quite new in Powerapps....screenshot_patch.PNG Thanks in advance!

@ejdregmans 

What column type is Status?  Text or Yes/No?

Status is Yes/No with required checked on

@ejdregmans 

OK, then we cannot use the words YES & NO like you had initially.  We must instead use true & false as shown below.

Set(currentRecord, LookUp(aanwezigheidMedewerkers;'medewerker number'=BarcodeScanner1_1.Value));
Patch(
    aanwezigheidMedewerkers;
    currentRecord;
    {
        status: Switch(currentRecord,
                       true, false,
                       false, true
                )
    }
)


---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up." 

v-xida-msft
Community Support
Community Support

Hi @ejdregmans ,

Do you want to update an existing record in your SP List via scanning the unique barcode for each employee?

 

Actually, I think it is not necessary to add a Timer control to achieve your needs. I think the OnScan property of the BarcodeScanner control could achieve your needs.

Please set the OnScan property of the BarcodeScanner control to following:

Patch(
      aanwezigheidMedewerkers;
      LookUp(aanwezigheidMedewerkers;'medewerker number'=BarcodeScanner1_1.Value);
      {
        status: If(
                   LookUp(aanwezigheidMedewerkers;'medewerker number'=BarcodeScanner1_1.Value).status = true,
                   false,
                   true
                )
      }
)

Note: When assigning value to Yes/No type column in SP List, you need to use true or false Boolean value

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks a lot. This works! and yes without timer

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PWREduCon768x460.png

Join us at PWR EduCon - A Power Platform Conference

Learn from the top Power BI, Power Apps, Power Automate & Power Virtual Agents experts!

Top Solution Authors
Top Kudoed Authors
Users online (3,172)