cancel
Showing results for 
Search instead for 
Did you mean: 

Building XML from Collection containing nested collection

EmmettBlake
Level 4

This is a work-around attempt.

I am attempting to consume a SOAP API  where methods define input/output parameters with Request/Response objects. Importing the WSDL/XSD creates methods without input/output parameters.

Blue Prism Support indicates complex datatypes (groups) are not supported and I should use the HTTP VBO to consume the SOAP service.

In order to consume the SOAP service, I need to build XML for the HTTP VBO.

I built a VBO with a method to convert a collection to an xml string.

Problem/Question.

Using the Utility Collection Manipulation VBO I was able to 

  • Extract a list of fields and data types from the collection.
  • For Text fields get value of fields.
  • Create Text string with begin / end tag with value

When I encounter a field name of nested collection, I am unable to use the field name to get the collection to apply the primitive field logic to.

How do I use field name to access nested collection.

Picture of described VBO method.

7827.png



------------------------------
Emmett Blake
Automation Developer
TMHP
America/Chicago
------------------------------

6 REPLIES 6

Hello Emmet,

Is there any possibility of extracting the nested collection before creating the long XML string? What I mean is, first create the XML string for the nested collection and then add it to the main string when needed.

I once had a process with many nested collections, 15 aprox (such as clients with products, economic groups, experian info, etc.) obtained through various internal and external platforms of a bank. Long story short, they needed an HTML report consolidating all the client data. What I did back then was extract all the nested collections, and for each one, I created a table inside a div. Then, when all the divs were created, I joined them using a calc stage, creating a data item type text just like did with [ResultingXml]  and then using that to create the HTML file that was perfectly visible to the business.

Is it possible to apply something similar in your case?

Regards



------------------------------
If this was helpful, please mark it as the best answer 🙂
Daniel Sanhueza
RPA Professional Developer
Deloitte
America/Santiago
------------------------------
Daniel Sanhueza
RPA Professional Developer
Deloitte

Hi Daniel,

Tell me more.

The challenge I think I have is I can identify the name of the collection but cannot access the identified collection.

In the example I am able to use the collection manipulation VBO method Read Collection Field and get text back.

If it is the field type is collection I have not found a way to address the [Collection.[NestedCollection]]

Blue Prism doesn't seem to have facility for dynamic interpolation, and I haven't found an object.method to return to me a copy of the nested collection.



------------------------------
Emmett Blake
Automation Developer
TMHP
America/Chicago
------------------------------

I see, instead of use Read Collection Field, simply use calculation stage to extract all the data that you need. 

For example, Main Collection has 3 fields, one of wich is a nested collection with data in it.

7789.png
7790.png

So, the following flow is very simple and you can extract all the data with a simple multi calculation stage.

7791.png

To extract the data, simply call the fields and save it on a Data item of the same type, Blue Prism allow some cast, like number to text, date to text and so on but it is better to maintain the same data type.

7793.png

Set next step and you can see the values in our data items.

7794.png

This is only an example, first you have to loop Main Collection to change the index of the row, then you have to do a nested loop to extract the data of "Current Products", with that you can work on.

Hope it helps!

Regards



------------------------------
Daniel Sanhueza
RPA Professional Developer
Deloitte
America/Santiago
------------------------------
Daniel Sanhueza
RPA Professional Developer
Deloitte

Daniel,

That example will work, but only for a specific collection.

I was trying to create a reusable widget that would create xml from any collection.

if a calc or multi-calc allowed dynamic/variable interpolation I would jump on it.

Dynamic/Variable interpolation might look something like 

[collection.[Collection Fields.Field Name]]

Where Collection Fields was populated by

7797.png

7798.png



------------------------------
Emmett Blake
Automation Developer
TMHP
America/Chicago
------------------------------

Emmett,

It might be as simple as your formatting.  In my [limited] experience of working with nested collections, the identification I have used has been:

[NamePrimaryCollection.NameNestedCollection1.NameNestedCollection2.NameColumn]

That is, there are no internal square brackets.  I don't know how to better say this than, the name of the nested collection is treated like the name of any standard column/field.  All of this is predicated on your various names being constant or known.  Otherwise, I have had to resort to something akin to what Daniel has suggested.

I hope this helps.

Red



------------------------------
Robert "Red" Stephens
Application Developer, RPA
Sutter Health
Sacramento, CA
------------------------------
Robert "Red" Stephens Application Developer, RPA Sutter Health Sacramento, CA

Hi Red,

You are absolutely right an explicit path seems to be the only option for calc/multi-calc.

My challenge is how to dynamically access nested collections without foreknowledge of collection structure.



------------------------------
Emmett Blake
Automation Developer
TMHP
America/Chicago
------------------------------