SelfSolved:Dt_inputを辞書変数dic_messageに代入したら静的エラー発生

こんにちは
UiPath Studio 2025.0.161 community editionのユーザです。

ForEachRowアクティビティでdt_inputを辞書変数dic_messageに代入しようとしましたが、動的エラーが発生しました。
どこをどう修正すればよいでしょうか?

dt_input
|Code|Level|Message|
|A001|Error|RPA実行異常終了しました。|
|A002|Error|異常終了:UiPath.Presentations.Activitiesファイルのパスが無効です。|
|A003|Info|ErrorHandler_Terminate:Ended|

ForEachRowアクティビティ内の代入アクティビティは下記になります。

dic_message(row("Code").ToString.Trim)=row("Level").ToString + ","+ row("Message").ToString

実行時エラーですね。

dic_messageかrowのいずれか、または両方がnullかとおもいますので、それ以前のロジックを確認いただいた方が良いかと思います。

Hi @gorby

The error occurs because the dictionary dic_message is not initialized before adding values.

Fix:

Before the For Each Row loop, initialize the dictionary using an Assign activity.

dic_message = New Dictionary(Of String, String)

Modify the assignment inside the loop to avoid errors.

If Not dic_message.ContainsKey(row("Code").ToString.Trim) Then
    dic_message(row("Code").ToString.Trim) = row("Level").ToString + "," + row("Message").ToString
End If

This ensures that dic_message is properly initialized and avoids key duplication errors.

1 Like

辞書変数インスタンス生成を忘れていました。

It should work if you assign default value for your dictionary. I echo @prashant1603765

Tested from my side as well

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.