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

Generating random serial number when sending form

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Generating random serial number when sending form

@imrineeman 

Try this:

 

Set(varPatchRecord, LookUp(your_datasource_name, ID=Form1.LastSubmit.ID));

Patch(your_datasource_name, varPatchRecord, {SerialNumber: Text(varPatchRecord.ID, “00000”)})

 

I changed the code and missed some brackets earlier.

---
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."

View solution in original post

9 REPLIES 9
Highlighted
Super User
Super User

Re: Generating random serial number when sending form

@imrineeman 

Actually, you don’t need the number to be random.  It creates the problem of having to check for duplicates.  Make a 5 digit number based off of the Item ID instead.


To do this, put my code in the OnSuccess property of your form.  It will insert the serial number for the Item after the ID is known.

 

Patch(your_datasource_name, LookUp(your_datasource_name, ID=Form1.LastSubmit.ID), {SerialNumber: Text(ID, “00000”})

 

Make sure serial number is a text type column so the leading zeros show

 

---
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."

Highlighted
Regular Visitor

Re: Generating random serial number when sending form

I'm getting an error on this stage: Text(ID,“00000”) (expected operator, the function text has invalid arguments)

 

Thanks for helping

Highlighted
Regular Visitor

Re: Generating random serial number when sending form

Fixed it, but it says that ID identifier isn't recognized..

Highlighted
Super User
Super User

Re: Generating random serial number when sending form

@imrineeman 

Try this:

 

Set(varPatchRecord, LookUp(your_datasource_name, ID=Form1.LastSubmit.ID));

Patch(your_datasource_name, varPatchRecord, {SerialNumber: Text(varPatchRecord.ID, “00000”)})

 

I changed the code and missed some brackets earlier.

---
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."

View solution in original post

Highlighted
Regular Visitor

Re: Generating random serial number when sending form

Thanks for your help.

Still same issue , on this function : Text(varPatchRecord.ID,“00000”)

Highlighted
Super User
Super User

Re: Generating random serial number when sending form

@imrineeman

Are you using SharePoint as a datasource?  Can I please see a screenshot of the formula showi the error?

 

---
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."

Highlighted
Regular Visitor

Re: Generating random serial number when sending form

Yes to sharepoint as db.

Capture.JPG

 

Hope this is enough

 

Thanks again!

Highlighted
Super User
Super User

Re: Generating random serial number when sending form

@imrineeman 
You need to retype the quotation marks.  Delete them and then retype.  Its because you cut + paste my code directly from this forum and I type it on my mobile.


(Its a silly quirk of our forums).

---
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."

Highlighted
Regular Visitor

Re: Generating random serial number when sending form

Works as a charm!

 

I thank you very much for your patience and help. 🙂

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (4,341)