web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : LoJp1/TCIf83b208ruLUX1
Power Apps - Building Power Apps
Answered

Best practice ticket number

Like (0) ShareShare
ReportReport
Posted on 3 Oct 2022 15:14:22 by

Dear all,

I have created an app that should create a unique ticket number when a end user submits a ticket. 
My app is running on a SharePoint list, where I have created an column "Ticket number" I imported this field to my Edit form and set the default to sum(Last('Sharepointlist').ID+100001) when the last id is 10 it should give me a ticket number of 1000011 and this workes fine.

The issue is that when 2 or more end users want to submit a ticket on the same time they all will get this ticket number, because the default ticketfield will get filled in on the time the ticket get opened. So I created the next solution:

On the submit button where I Submit the form I have entered the following code:
Set(ticketnumber,true);
SubmitForm(Form).

On the DataCardValue from the ticket number I have created the following code:
If(
   Ticketnumber = true,

    sum(Last('Sharepointlist').ID+100001)
)

With this solution I thought I could avoid duplicate ticket numbers, but somehow it still isn't working, I still get duplicates.
Is there any best practice for unique ticket numbers?

Thanks!

Ramon

Categories:
I have the same question (0)
  • Verified answer
    v-xiaochen-msft Profile Picture
    on 04 Oct 2022 at 02:20:13
    Re: Best practice ticket number

    Hi @Anonymous ,

     

    Please try this formula:

    SubmitForm(Form1);Patch(LIST278,LookUp(LIST278,ID=Form1.LastSubmit.ID),{'Ticket number':Form1.LastSubmit.ID+100000})

    Now the datacard of ticket number is no longer needed in form.

     

    Best Regards,

    Wearsky

  • Community Power Platform Member Profile Picture
    on 04 Oct 2022 at 13:28:35
    Re: Best practice ticket number

    Hi @v-xiaochen-msft ,

    Thank you for your reply, my current code with your adjustmnts looks like this:

    CCRNewticket.Run(Last('AR support request').ID+1);
    Patch('AR support request',Defaults('AR support request'),Form1.Updates,Form2.Updates);
    Patch('AR support request',LookUp('AR support request',ID=Form1.LastSubmit.ID),{'Ticket number':Form1.LastSubmit.ID+100000});
    Navigate(Home);
    ResetForm(Form1);
    ResetForm(Form2)

    When I submit the ticket there is no ticket number visable, did I miss something?

    In the first Patch function I am submitting form 1 and 2 as a combined 

  • Verified answer
    v-xiaochen-msft Profile Picture
    on 05 Oct 2022 at 01:22:04
    Re: Best practice ticket number

    Hi @Anonymous ,

     

    Form.LastSubmit.ID is blank because you don't actually use SubmitForm function.

    Please try this:

    CCRNewticket.Run(Last('AR support request').ID+1);
    Set(var,Patch('AR support request',Defaults('AR support request'),Form1.Updates,Form2.Updates));
    Patch('AR support request',var,{'Ticket number':var.ID+100000});
    Navigate(Home);
    ResetForm(Form1);
    ResetForm(Form2)

     

    Best Regards,

    Wearsky

  • Community Power Platform Member Profile Picture
    on 05 Oct 2022 at 10:55:33
    Re: Best practice ticket number

    This is great, thank you so much!

  • knsrinath Profile Picture
    527 on 14 Mar 2023 at 17:44:45
    Re: Best practice ticket number

    Hi @v-xiaochen-msft 

     

    I have same issue, I am not using form control.

    I am using following code for generating the Ticket No 

     

    In patch 

    SLNo:First(Sort(mySPList, SLNo, SortOrder.Descending)).SLNo+1,
    orderNo:Text(First(Sort(mySPList, SLNo, SortOrder.Descending)).SLNo+1,"00000"),

     

    I am not using default sharepoint ID column.

     

    Request you help me resolve the issue.

     

    Thanks & Regards

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 629 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 397 Super User 2025 Season 2

#3
wolenberg_ Profile Picture

wolenberg_ 232 Moderator

Last 30 days Overall leaderboard
Loading complete