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

How create a table in XML and add data dynmically from collection or gallery?

Hi Experts, 

I have been working on some functionality where we can achieve or transfer the data using XML as you all know it's more convenient and fast to transfer data for certain old software application do not support JSON. 

However, I have a requirement, when I would like to create an XML file, using the data entered in powerapps. So far I have figured out how and what ways can this be achieved but one thing is missing or I do not know how can this be resolved. 

I would like to add the data to the XML table dynamically from the collection/gallery. such that if there are 5 rows in the gallery it takes data from the gallery and adds it to the XML. I know this can be achieved in HTML by using Concat/Concatenate function but is there a similar way for XML too? if not how can this be achieved any idea? 


Thanks a million for taking the time to read the long post and helping me out. 

Please find the  code below:

<GLEntries>
<GLEntry>
      <Division code= "& """001""" &" />
      <Description> "& Concatenate(
            "PC-",
            Text(ExportUnitName.Text),
            "-",
            (Text(
                Now(),
                ShortDate
            )))
        &" </Description>
      <Date>  "& Text(
                ExportCreated.Text,
                "yyyy-mm-dd")
             &" </Date>
      <DocumentDate>"& Text(
                ExportCreated.Text,
                "[$-en-GB] yyyy-mm-dd")
             &" </DocumentDate>
      <Journal code="& """501""" &" type = "& """I""" &"/>
      <Costcenter code= "& Concatenate( """" , ExportUnitCode.Text , """") &"/>
      <Costunit code= "& """D001""" &" />


      <FreeFields>
        <FreeNumbers>
          <FreeNumber number=""4""> "& "16002" &" </FreeNumber>
        </FreeNumbers>
      </FreeFields>

      <Amount>
        <Currency code= "& """EUR""" &" />
        <Value> "& Text(ExportWeeklyTotal.Text) &" </Value>
      </Amount>
    

      <FinEntryLine type= "&  """N"""   &" subtype= "& """T""" &" number= "& """1""" &">
        <Date> "& ExportP_Date.Text &" </Date>
        <GLAccount code="& Left(
                ExportGLcode.Text,
                5
            ) &"/>
        <Description>"& ExportDescription.Text &"</Description>
        <Costcenter code="& Concatenate( """" , ExportUnitCode.Text , """") &" />
        <Costunit code= "& """D001""" &" />
        <Creditor code= "& Concatenate( """" , ExportCreditorNo.Text , """") &" />
        <FreeFields>
          <FreeNumbers>
            <FreeNumber number= "& "4" &" >"& "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="& """2084""" &"/>
                </Account>
            <OurRef>"& "1636539" &"</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>


</GLEntry>
</GLEntries>





2 REPLIES 2
StalinPonnusamy
Community Champion
Community Champion

Hi @Tapesh

 

As per knowledge, There is no way to create XML other than concatenating that already you are doing. So you are on the right track.

 

BCLS776
Super User
Super User

A suggestion for doing this:

  • Before you create your main XML file, do a ForAll on the AllItems of your gallery to generate a string with the appropriate XML tags. Put that string into a variable.
  • As you create the rest of your XML file, you can concatenate your new variable into the rest of the XML string

Here's another post referencing the difficulty of working directly with XML in PowerApps: https://powerusers.microsoft.com/t5/Building-Power-Apps/How-do-I-generate-an-xml-file-from-data-capt... 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,814)