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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Generate serial number...
Power Apps
Unanswered

Generate serial number not working properly

(0) ShareShare
ReportReport
Posted on by 603

I have a powerapps screen with SharePoint as the backend which has the Item number column numbered 1000,1001,1002,1003.

 

I am trying to split an item and generate serial number in the following format 1000-1, 1000-2,1000- and then delete the original item with number 1000 once split is performed.

 

Below is the code i am using which works fine sometimes. Sometime it generates serial number in format 1000-0,1000-1 and so on.

 

I want the serial number in finite order starting from 1 instead of 0. Any idea where i am going wrong?

 

Screen OnVisible

Collect(
SplitCollection,
{LineNum: 0}
);

 

Add new button

Set(
TotLines,
TotLines + 1
);
Collect(
SplitCollection,
{LineNum: TotLines}
);

 

Reset button

Clear(SplitCollection);Set(TotLines,0)

 

Gallery Serial Number TextInput Box default 

currentrecord.'Serial No'&"-"&ThisItem.LineNum

 

Submit Button

ForAll(
Gallery2.AllItems,
Patch(
DataSource,
Defaults(DataSource),
{
Declaration_No: TextInput1.Text,
'Serial No': TextInput3.Text,
}
)
);
Remove(
Datasource,
currentrecord
);
Clear(SplitCollection);
Set(
TotLines,
1
);

Categories:
  • developerAJ Profile Picture
    4,763 on at

    Collect(
    SplitCollection,
    {LineNum: 0}
    );

    so by default you are adding one row to a gallery with linenum 0 if you want to start number with 1 make this 

    Collect(
    SplitCollection,
    {LineNum: 1}
    );

     

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 258

#3
Mohsin Ali Profile Picture

Mohsin Ali 231

Last 30 days Overall leaderboard