rpa - Blue Prism - 获取没有字段名称的集合元素
问题描述
我在使用集合时遇到了一些麻烦,因为设置的字段名称并不总是很好用(我检查了 100 次名称都可以),所以我想通过它的索引从集合中获取一个元素值。类似于: Coll(2,3) 给了我第三列的第二行。
我知道有一个读取集合字段操作,但它需要字段名称:
If RowIndex < 0 OrElse Coll.Rows.Count <= RowIndex Then
Throw New ApplicationException("The supplied row index falls outside of the valid range.")
End If
If Not Coll.Columns.Contains(FieldName) Then
Throw New ApplicationException("The collection does not contain a field with the name '" & FieldName & "'")
End If
Value_Read = CStr(Coll.Rows(RowIndex)(FieldName))
如何将 FieldName 替换为 ColIndex 或类似的东西?
谢谢 :)
解决方案
一种方法是创建一个全新的 VBO,其操作调用代码阶段,代码类似于以下代码,检索 中指定索引处的值DataTable
:
value_out = CStr(coll_in.Rows(CInt(row_index))(CInt(col_index)))
在这种情况下,您必须创建动作、动作输入、动作输出、代码阶段输入、代码阶段输出以及其他 VBO 配置任务。
或者,您可以将以下 XML 定义复制/粘贴到.xml
文件中,然后将其导入您的 Blue Prism 环境,该环境将为您处理大量设置:
<process name="Utility - Collection Manipulation (enhanced)" version="1.0" bpversion="6.8.0.23415" narrative="" byrefcollection="true" type="object" runmode="Exclusive" preferredid="85cc6944-6bb6-4d9f-80a3-730f6795a0a7">
<appdef>
<element name="Application Root">
<id>b282c66c-7516-49bf-ab60-67ebeecbd1f5</id>
<type>Application</type>
<datatype>unknown</datatype>
<diagnose>False</diagnose>
</element>
</appdef>
<view>
<camerax>0</camerax>
<cameray>0</cameray>
<zoom version="2">1.25</zoom>
</view>
<preconditions />
<endpoint narrative="" />
<subsheet subsheetid="66499b03-6862-4453-bd13-1a161b85f07d" type="CleanUp" published="True">
<name>Clean Up</name>
<view>
<camerax>0</camerax>
<cameray>0</cameray>
<zoom version="2">1.25</zoom>
</view>
</subsheet>
<subsheet subsheetid="fa2065da-c98e-461d-8478-03ae6217eb2a" type="Normal" published="True">
<name>Get Collection Cell</name>
<view>
<camerax>0</camerax>
<cameray>0</cameray>
<zoom version="2">1.25</zoom>
</view>
</subsheet>
<stage stageid="47a95b72-9237-4e80-a094-60254bed0627" name="Start" type="Start">
<loginhibit />
<display x="15" y="-105" />
<onsuccess>b10f75e7-f56e-4c2f-84fd-96b0f1c3654a</onsuccess>
</stage>
<stage stageid="b10f75e7-f56e-4c2f-84fd-96b0f1c3654a" name="End" type="End">
<loginhibit />
<display x="15" y="90" />
</stage>
<stage stageid="c8e7d332-e00b-4b36-a264-ea9e1cc18968" name="Stage1" type="ProcessInfo">
<display x="-195" y="-105" w="150" h="90" />
<references>
<reference>System.dll</reference>
<reference>System.Data.dll</reference>
<reference>System.Xml.dll</reference>
<reference>System.Drawing.dll</reference>
<reference>Microsoft.VisualBasic.dll</reference>
</references>
<imports>
<import>System</import>
<import>System.Drawing</import>
<import>System.Data</import>
<import>System.Collections</import>
</imports>
<language>visualbasic</language>
<globalcode><![CDATA[]]></globalcode>
<code><![CDATA[]]></code>
</stage>
<stage stageid="f703c095-8cf1-4d2f-b9d1-6762853bcdb7" name="Clean Up" type="SubSheetInfo">
<subsheetid>66499b03-6862-4453-bd13-1a161b85f07d</subsheetid>
<display x="-195" y="-105" w="150" h="90" />
</stage>
<stage stageid="aa0d2e87-fb6d-4705-ad14-c4fca090b773" name="Start" type="Start">
<subsheetid>66499b03-6862-4453-bd13-1a161b85f07d</subsheetid>
<loginhibit />
<display x="15" y="-105" />
<onsuccess>c4e7cb3b-895e-49a0-8df5-a7c331088eb3</onsuccess>
</stage>
<stage stageid="c4e7cb3b-895e-49a0-8df5-a7c331088eb3" name="End" type="End">
<subsheetid>66499b03-6862-4453-bd13-1a161b85f07d</subsheetid>
<loginhibit />
<display x="15" y="90" />
</stage>
<stage stageid="a184281e-7d2b-4609-b970-e9d7ce403fe8" name="Get Collection Cell" type="SubSheetInfo">
<subsheetid>fa2065da-c98e-461d-8478-03ae6217eb2a</subsheetid>
<display x="-195" y="-105" w="150" h="90" />
</stage>
<stage stageid="121240c8-a621-4b66-a0cb-a48a8c0bf66c" name="Start" type="Start">
<subsheetid>fa2065da-c98e-461d-8478-03ae6217eb2a</subsheetid>
<loginhibit />
<display x="15" y="-105" />
<inputs>
<input type="collection" name="Collection In" narrative="The collection from which to read the given cell." stage="Collection In" />
<input type="number" name="Row Index" narrative="The row index from which to read the cell." stage="Row Index" />
<input type="number" name="Column Index" narrative="The column index from which to read the cell." stage="Column Index" />
</inputs>
<onsuccess>41aa3760-b489-4cb2-9c73-040a7c946bdf</onsuccess>
</stage>
<stage stageid="0173157c-0b87-4d11-a063-877018291918" name="End" type="End">
<subsheetid>fa2065da-c98e-461d-8478-03ae6217eb2a</subsheetid>
<loginhibit />
<display x="15" y="90" />
<outputs>
<output type="text" name="Cell Value" narrative="The value read from the cell at the specified indices." stage="Cell Value" />
</outputs>
</stage>
<stage stageid="ad6b171c-3666-4b39-80bb-7b002d941911" name="Note1" type="Note">
<subsheetid>66499b03-6862-4453-bd13-1a161b85f07d</subsheetid>
<narrative>Clean Up Page
This is an optional page where you might choose to perform some finalisation (or "cleanup") tasks as your business object is closed down.
The cleanup action will be called automatically immediately after closing your business object at the end of a business process.
You will not be able to call this action from a business process, nor will it be called at any other time than before the disposal of the business object.</narrative>
<display x="-180" y="60" w="180" h="230" />
</stage>
<stage stageid="b726df4a-77b4-463d-8b12-949b1b8653b5" name="Note2" type="Note">
<narrative>Initialise Page
This is an optional page where you might choose to perform some initialisation tasks after your business object is loaded.
The initialise action will be called automatically immediately after loading your business object.
You will not be able to call this action from a business process, nor will it be called at any other time than after the creation of the object.</narrative>
<display x="-180" y="60" w="180" h="230" />
</stage>
<stage stageid="c2d6c2f7-b765-425f-8a46-2d0ebaeb69a1" name="Collection In" type="Collection">
<subsheetid>fa2065da-c98e-461d-8478-03ae6217eb2a</subsheetid>
<display x="-195" y="-15" w="150" h="60" />
<datatype>collection</datatype>
<private />
<alwaysinit />
</stage>
<stage stageid="78c5c116-5ff2-4c02-a599-7c860ef84035" name="Row Index" type="Data">
<subsheetid>fa2065da-c98e-461d-8478-03ae6217eb2a</subsheetid>
<display x="-195" y="30" w="150" h="30" />
<datatype>number</datatype>
<initialvalue />
<private />
<alwaysinit />
</stage>
<stage stageid="03368ae5-05d1-4f9b-96b9-89e141228cc0" name="Column Index" type="Data">
<subsheetid>fa2065da-c98e-461d-8478-03ae6217eb2a</subsheetid>
<display x="-195" y="60" w="150" h="30" />
<datatype>number</datatype>
<initialvalue />
<private />
<alwaysinit />
</stage>
<stage stageid="41aa3760-b489-4cb2-9c73-040a7c946bdf" name="GetCellValue" type="Code">
<subsheetid>fa2065da-c98e-461d-8478-03ae6217eb2a</subsheetid>
<loginhibit />
<display x="15" y="-15" />
<inputs>
<input type="collection" name="coll_in" expr="[Collection In]" />
<input type="number" name="row_index" expr="[Row Index]" />
<input type="number" name="col_index" expr="[Column Index]" />
</inputs>
<outputs>
<output type="text" name="value_out" stage="Cell Value" />
</outputs>
<onsuccess>0173157c-0b87-4d11-a063-877018291918</onsuccess>
<code><![CDATA[value_out = CStr(coll_in.Rows(CInt(row_index))(CInt(col_index)))]]></code>
</stage>
<stage stageid="07759f58-4446-485b-bcba-3cf8aef21357" name="Cell Value" type="Data">
<subsheetid>fa2065da-c98e-461d-8478-03ae6217eb2a</subsheetid>
<display x="-195" y="105" w="150" h="30" />
<datatype>text</datatype>
<initialvalue />
<private />
<alwaysinit />
</stage>
</process>
推荐阅读
- c - STM32 CAN环回模式
- javascript - 使用 WebAssembly 在 Canvas 上绘制系列图像是否更快?
- reactjs - 当变量未定义时,是否可以使用 React 组件的条件渲染?
- version-control - Tortoise Mercurial - 合并 2 个提交
- reactjs - 每次单击按钮时将状态数据推送到数组
- javascript - IE 的“SCRIPT1010:预期标识符”错误的原因是什么?
- scala - (String, Int, Boolean) 类型的覆盖方法 => Double 具有不兼容的类型
- c++ - 提升进程间向量崩溃
- mysql - 如何在批量 INSERT 中使用 Node.js 中的 mysql / sqlstring 正确转义?
- keras - 我的模型 LSTM 损失中的问题:我的验证数据为 81.84%