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 / How to add sequence nu...
Power Apps
Answered

How to add sequence number from one gallery to collection or auto increment number in collection string?

(0) ShareShare
ReportReport
Posted on by 825

Hi All, 

I have been trying to achieve the functionality to add auto-increment numbers based on the number of records present in the gallery. However, I have an auto number in one of my galleries from which I am trying to reference the data and creating another collection.

So the issue is I am not getting the row number that I am trying to reference to my new collection string item. I am only getting the first number which is 0 and the rest is blank,

but on the same hand I am getting all the number if am using a separate column in my collection as you can see below which is xmlId, and this shows all the number. 

 

Please see that am trying to add ExportUniqueId.Text  i.e 

number= "& Concatenate(
"""",
ExportUniqueID.Text,
""""
) &">
 

from my ExportDataGal.allItems.  The detail code is as shown below. 

 

 

 

 

 

ForAll(
 ExportDataGal.AllItems,
 Collect(
 testColxmldata, 
 {xmlId: ExportUniqueID.Text, xmlData: 
 "<FinEntryLine type= "& """N""" &" subtype= "& """T""" &" number= "& Concatenate(
 """",
 ExportUniqueID.Text,
 """"
 ) &">
 
 <Date> "& ExportCreated.Text &" </Date> 

 <GLAccount code=" & Char(34) & Left(
 ExportGLcode.Text,
 5
 ) & Char(34) & "/>
 <Description>" & ExportDescription.Text & "</Description>
 <Costcenter code=" & Char(34) &
 varCostCenterCode
 & Char(34) & " />
 <Costunit code= " & """D001""" & " />
 <Creditor code= " & Concatenate(
 """",
 varCreditorCode,
 """"
 ) & " />
 <FreeFields>
 <FreeNumbers>
 <FreeNumber number= " & Char(34) & "4" & Char(34) & " >" & "16002" & "</FreeNumber>
 </FreeNumbers>
 </FreeFields>

 <Amount>
 <Currency code=" & """EUR""" & "/>
 <Debit> " & ExportDayTotal.Text & " </Debit>
 <Credit>" & "0" & " </Credit>
 <VAT code=" & """0""" & " />
 </Amount>

 <Payment>
 <InvoiceNumber>" & "123654" & " </InvoiceNumber>
 </Payment>

 <FinReferences>
 <YourRef>" & "RCT 114" & " </YourRef>
 <DocumentDate>" & Text(
 ExportCreated.Text,
 "yyyy-mm-dd"
 ) & "</DocumentDate>
 </FinReferences>

 <DocumentAttachment publish= " & """0""" & ">
 <DocumentType number=" & """7""" & "/>
 <Subject> " & "Invoice Name.pdf" & " </Subject>
 <Division code= " & """001""" & "/>
 <Account>
 <Creditor code= " & Concatenate(
 """",
 varCreditorCode,
 """"
 ) & " />
 </Account>
 <OurRef>" & "125463" & "</OurRef>
 <YourRef>" & "RCT 114" & "</YourRef>
 <FreeFields>
 <FreeNumbers>
 <FreeNumber number= " & """4""" & "> " & "16002" & "</FreeNumber>
 </FreeNumbers>
 </FreeFields>
 <Attachment>
 <Name> test.pdf </Name>
 <BinaryData>
 Add attachment code here (base64)
 </BinaryData>
 </Attachment>
 </DocumentAttachment>
 </FinEntryLine>"}
 )
) ; 

 

 



The fine result in the gallery: 

 

Tapesh_0-1628243449091.png

 

Thanks a million for taking the time to read and for your help.  

 

Categories:
I have the same question (0)
  • Verified answer
    StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @Tapesh 

     

    Make sure to clear the collection before use it. I have a subset of your code but should give the idea or concept.

     

     

    Clear(testColxmldata);
    Clear(MyCounter);
    
    ForAll(
     BrowseGallerySave.AllItems,Collect(MyCounter, 1); 
     Collect(
     testColxmldata,
     {
     xmlId: CountRows(MyCounter),
     xmlData: "<FinEntryLine type= " & """N""" & " subtype= " & """T""" & " number= " & Concatenate(
     """",
     Text(CountRows(MyCounter)),
     """"
     ) & ">
     <Date> " & Label5.Text & " </Date> </FinEntryLine>}"
     }
     );
    )

     

     

     

    StalinPonnusamy_0-1628374447556.png

     

     

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 356 Most Valuable Professional

#2
11manish Profile Picture

11manish 225 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 211

Last 30 days Overall leaderboard