0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【BluePrism】コレクションに連番を付与する

Last updated at Posted at 2021-12-21

やりたいこと

小ネタです。

コレクションに連番を付与したいときありますよね。
単純なことなのですが、いちいちプロセス側でループ回して連番セットしていくのはイヤだ。。。
というわけで、Utility - Collection Manipulationを拡張して作ってみました。

実装

アクション全体

image.png

開始ステージ

image.png

コードステージ

入力

image.png

出力

image.png

コード

コレクションの先頭列に連番フィールド(名前は任意に設定可)を追加して、各レコードに連番を付与しています。
image.png

If Not Collection.Columns.Contains(Column) Then

	Collection.Columns.Add(Column, Type.GetType("System.String"))

	Dim cnt As Long = 1
	For Each dr As System.Data.DataRow In Collection.Rows
		
		dr(Column) = CStr(cnt)
		cnt += 1
	Next

	Collection.Columns(Column).SetOrdinal(0)

Else
	Throw New Exception("The field already exists")
End If

New_Collection = Collection

実行結果

呼び出し元のプロセスの実装

Utility - Collection Manipulationオブジェクトの連番付与アクションを呼び出してます。
image.png

コレクション

このコレクションに連番を追加してみます。
image.png

連番付与アクション

入力

image.png

出力

image.png

結果

image.png

確かにコレクションの先頭列に連番が付与されており、連番の値も正しくセットされていることが確認できました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?