cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Tapesh
Post Prodigy
Post Prodigy

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

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.  

 

1 ACCEPTED SOLUTION

Accepted Solutions
StalinPonnusamy
Super User
Super User

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

 

 

View solution in original post

1 REPLY 1
StalinPonnusamy
Super User
Super User

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

 

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,441)