cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mareliese
Helper I
Helper I

Submit Form unique ID / number

I have an Online Job Card which the employees complete for each job they do.
Each Job Card are completed on the Power App and the data is saved into Excel.
In Excel, each Job Card is saved on a one liner on the tab.
Each Job Card gets a unique Job Card no, which is the " ID _ Column" column on the Excel tab. The ID Column follows in numerical order and each line which is a new Job Card follows.
The If function works fine, except if the Form is Submitted at +- the same time.
At the start of using the Online Job Card there weren't any issues with the If function. But now with more and more people using it, it happens that people Submits around the same time and the unique number " ID _ Column " is duplicated.
Thus, the If function doesn't work if the Submit button is pushed at +- the same time.
Any suggestions on another check to build in, will be truly appreciated.
Is there perhaps a time-delay function which will work and can be included?
Any suggestions will be awesome.
Thank you!

 

If(
!IsBlank(LookUp(JobCardMetering,
ID_Column = DataCardValue_JobCardNo.Text
)
) &&
IsBlank(LookUp(JobCardMetering,
Job_Complete = Dropdown_Complete.SelectedText.Value
)
),
SubmitForm(EditForm1_Intro),
Notify(
"The process was started. And the Job Card no. was generated. Complete the process.",
NotificationType.Error
)
);
Refresh(JobCardMetering); 
SubmitForm(EditForm1_Intro)

 

 

4 REPLIES 4
Drrickryp
Super User
Super User

Hi @Mareliese 

You can assign the ID in the OnSuccess property of your form by Patching it immediately when the record is created. 

Patch(
      JobCardMetering,Editform1_Intro.LastSubmit,
       {ID:First(
                 Sort(
                      JobCardMetering, ID, Descending
                  )
            ).ID+1
         }
)

 

Thank you. It worked except that the new ID Column unique number allocated to the 'double' ID number, started at 1000 and added +1 from 1000. I amended the Patch as per below which is working, it allocates the next number on the Excel column and saves it on the Excel. The next step is just to Refresh the Job Card No. / ID number on the second screen of the application. On the 2nd screen the old / incorrect ID Column number sticks / reflects again and then moving from the 2nd tot he 3rd screen, the incorrect ID Column number is saved back to Excel. Thanks for the help. 

Spoiler
Patch(JobCardMetering,EditForm1_Intro.LastSubmit,
{ID_Column:Max(JobCardMetering,ID_Column)+1
}
);

 

Apologies for inserting it as a spoiler. Wrong button 😊. What exactly is a Spoiler? Thank you 😁

Patch(JobCardMetering,EditForm1_Intro.LastSubmit,
{ID_Column:Max(JobCardMetering,ID_Column)+1
}
);

Dear Drrickryp, any more thoughts will be awesome. 

As per your patch, the new ID Column's unique number starts at 1000 and ads 1. It doesn't not take the last listed number and ads 1. 

My patch ads 1 to the ID Column each and every time, not only when it is a double ID Column number. 

Thank you

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.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,561)