cancel
Showing results for 
Search instead for 
Did you mean: 

#BPTechTip XML manipulation to avoid excessive manual text entry

John__Carter
Staff
Staff
Sometimes during development you'll have a long list of field names to enter into BP that you know will be painful to type in and you're likely to make mistakes. But knowing that BP diagrams are based on XML, there are workarounds for faster and accurate data entry.

For example, if you paste a collection into a text editor capable of formatting XML (eg Notepad++), you'll begin to understand how the XML is structured. And importantly, you can also edit the XML and paste back into BP - obviously the XML has to be valid, but BP will not let you paste 'bad XML' back into the diagram.

Once you realise this copy-edit-paste trick works, it opens up possibilities to save time, and the attached Excel is a an example tool you can use with long lists of fields.

Collection Field Names
Here you'll see a collection and its corresponding XML.
23637.png
Now lets imagine the collection needs to have 50 fields. Rather than enter them manually, you could paste them into the 'Names and Types' page of the Excel tool and use the formulas on the 'Collection Field XML' page to generate the XML necessary for BP collection fields.

Then you can replace the old field elements with the new elements by simply pasting from Excel into the text editor (Note - the indentation/whitespace doesn't matter).
23638.png
23639.png
Then copy all the XML from the text editor back into BP. Your collection now has 50 fields!

23640.png
This hack isn't worth the effort for a handful of fields but it can save you a lot of pain when setting up a large collection.

NOTE: the attachment is provided 'as is' and is not an officially supported BP product. Feel free to use it as you see fit.

#BPTechTips
​​
4 REPLIES 4

John__Carter
Staff
Staff
Inputs and Outputs
The same principle can be applied to Start stage inputs or End stage outputs. Set up a stage with an input and paste into your text editor:
23609.png
Use the 'Input XML' page in the Excel file to generate XML using the names on the 'Names and Types' page. Then paste back into the editor to replace the original input elements.
23610.png
Then paste all the XML back into BP.
23611.png

John__Carter
Staff
Staff
Multicalcs
If you wanted to use a multicalc to transfer data between collections that have many fields, use the 'Multi Calc XML' page in a similar manner.

Set up a basic multicalc and paste into the text editor.
23617.png
Generate the replacement XML elements using the Excel tool, paste into the text editor and then paste everything back into BP.
23618.png

John__Carter
Staff
Staff
Collection Initial Data Rows
Let's say you have a simple collection that needs many rows of 'initial value' data that you don't want to have to enter manually.

Set up you collection with the necessary fields, create one row on the initial values tab, and then copy to the text editor.
23623.png
In the Excel tool, go to the Collection Row XML page, create the field names you require and paste in the data values.
23624.png
Edit the 'template XML' cell to match your column names - this part is a little tricky to get right but you should be able to understand the example. Then copy the orange cell down to generate the XML elements.
23625.png
Then as before, copy the XML elements back into the text editor to replace the original row element. And then copy everything back into BP.
23626.png

John__Carter
Staff
Staff
Compound/Nested Collections
Compound collections are, as you can imagine, more awkward and the Excel tool is unlikely to be useful for anything but 'shallow' nesting.

The 'Compound Collection Row XML' page in the Excel tool follows the same pattern as the 'Collection Row XML' page but with more complex formulas.

23631.png 
23632.png