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>

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...