[XML Records] Parameters of XmlToRecordList

Forge Component
(39)
Published on 27 May by João Melo
39 votes
Published on 27 May by João Melo

Hi, Congratulations on the component. I have a question, I need to transform a complex structure with records inside records and I do not know how to do it. With a simple structure, that's fine, but the other is not. Maybe I have to use some of the other input parameters, XmlConfig, IgnoreXmlDeclarations or AttributePrefix, but I do not find instructions on how to use these parameters.

Thank you.

Hi Clayton, I had a similar problem creating credit transactions on a bulk payment process. The bank's structure had multiple record lists within it. My solution to the problem was as follows;

For each of the records lists within the main structure I created a local variable for each of them.

  • I then used the "ListAppend" server action to populate all the data records into each of the local variable records lists.
  • I then used the "ListAppend" server action to add each of the populated 'local variable record lists' into the main structure.
  • I then passed this into the "RecordListToXml" server action.

The only changes I had to make to the XMLConfig records was to set the "RecordName", "NameSpace" and the "EffectiveName". In my example I also set the XmlDeclaration.AddDeclaration = true, but you may or may not need to do this.

Is it possible for you to share a copy of the structure? 

Regards, John.





The issue is that I need to send the XML file to the structure and not the other way around. The problem I'm having is that the XmlToRecordList call is not feeding the structure correctly, for a simple structure I've managed to do, but for this I'm attaching attachment not. Do I have to change my structure? Any input parameters?

Tanks.

Xml:

<?xml version="1.0" encoding="UTF-8"?>
<representative-insert>
<representative-info>
<rep_key_search>9999999918940947861</rep_key_search>
<rep_fullname>Maria Juliana Ruiz</rep_fullname>
<rep_birthday>09121999</rep_birthday>
<rep_cpf>18940947861</rep_cpf>
<rep_gender>F</rep_gender>
<rep_maritalStatus>M</rep_maritalStatus>
<rep_scholarship>3</rep_scholarship>
<rep_accNumber>999999999</rep_accNumber>
<rep_saleszone>543</rep_saleszone>
<rep_team>12</rep_team>
<rep_loa>57</rep_loa>
<rep_los>57</rep_los>
<rep_acc_status>A</rep_acc_status>
<rep_acc_type>REP</rep_acc_type>
<rep_tag_e>1</rep_tag_e>
<rep_appointment_dt>14042014</rep_appointment_dt>
<rep_appointment_cp>7</rep_appointment_cp>
<rep_appointment_yr>2014</rep_appointment_yr>
<rep_curr_cred_lim>0000000000044321</rep_curr_cred_lim>
<rep_curr_cred_lim_last_update>11042019</rep_curr_cred_lim_last_update>
<rep_curr_cp>7</rep_curr_cp>
<rep_curr_cp_yr>2019</rep_curr_cp_yr>
<rep_returned_box>Y</rep_returned_box>
<rep-categories-info>
<rep_cat_type>1</rep_cat_type>
<rep_cat_value>4</rep_cat_value>
<rep_cat_type>2</rep_cat_type>
<rep_cat_value>4</rep_cat_value>
<rep_cat_type>3</rep_cat_type>
<rep_cat_value>D</rep_cat_value>
<rep_cat_type>4</rep_cat_type>
<rep_cat_value>Y</rep_cat_value>
<rep_cat_type>5</rep_cat_type>
<rep_cat_value>V</rep_cat_value>
<rep_cat_type>6</rep_cat_type>
<rep_cat_value>Y</rep_cat_value>
</rep-categories-info>
</representative-info>
</representative-insert>

Hi Clayton, you to define all the attributes of a complex type as Record List of something, or Record of something.

Take a look at this article to see the differences: https://www.outsystems.com/forums/discussion/14342/from-record-lists-to-lists/

Basically, Lists are a new approach, and XML Records component is still working with Recod Lists.

Oh yes, I use the Record List, but it is assigned in the internal structure of my action. Look:

João Melo wrote:

Hi Clayton, you to define all the attributes of a complex type as Record List of something, or Record of something.

Take a look at this article to see the differences: https://www.outsystems.com/forums/discussion/14342/from-record-lists-to-lists/

Basically, Lists are a new approach, and XML Records component is still working with Recod Lists.



I meant in your structure. How is the repcategoriesinfo attribute defined?

And I see now that this part of your XML is invalid:

<rep-categories-info>
<rep_cat_type>1</rep_cat_type>
<rep_cat_value>4</rep_cat_value>
<rep_cat_type>2</rep_cat_type>
<rep_cat_value>4</rep_cat_value>
<rep_cat_type>3</rep_cat_type>
<rep_cat_value>D</rep_cat_value>
<rep_cat_type>4</rep_cat_type>
<rep_cat_value>Y</rep_cat_value>
<rep_cat_type>5</rep_cat_type>
<rep_cat_value>V</rep_cat_value>
<rep_cat_type>6</rep_cat_type>
<rep_cat_value>Y</rep_cat_value>
</rep-categories-info>

The items in your list should be wrapped like this:

<rep-categories-info>
<rep_cat_type>1</rep_cat_type>
<rep_cat_value>4</rep_cat_value>
</rep-categories-info>

<rep-categories-info>
<rep_cat_type>2</rep_cat_type>
<rep_cat_value>4</rep_cat_value>
</rep-categories-info>

<rep-categories-info>
<rep_cat_type>3</rep_cat_type>
<rep_cat_value>D</rep_cat_value>
</rep-categories-info>

<rep-categories-info>
<rep_cat_type>4</rep_cat_type>
<rep_cat_value>Y</rep_cat_value>
</rep-categories-info>

<rep-categories-info>
<rep_cat_type>5</rep_cat_type>
<rep_cat_value>V</rep_cat_value>
</rep-categories-info>

<rep-categories-info>
<rep_cat_type>6</rep_cat_type>
<rep_cat_value>Y</rep_cat_value>
</rep-categories-info>

Clayton, as per our last chat, there is another issue with your XML (commenting here to help others).

There are invalid characters in some of the fields. Hyphens/dashes ('-') are not accepted. When you create a structure Service Studio will ret ride of it. So this XML will never be parsed.

You can either change the extension to replace those characters before parsing the XML, or change the structure in the source system.

Hi, I discovered the problem, my client 's xml is badly formatted, besides it does not accept the "-" hyphen in the tags name. I'll hit the same and if you still have problems I put here.

Thank you.