キューに関わるエラーの解決方法:トランザクションのステータスを設定: Object reference not set to an instance of an object

トランザクション関連エラーの件、質問させてください。

トランザクションのステータスを設定アクティブでキューアイテムのステータスを成功に変更したいです。

同じキューに対して:
①シンプルのフローでトランザクション アイテムを取得して、トランザクションのステータスを設定するとエラーがありませんでした。

②ちょい複雑のフローでもエラーがありませんでした。

③トランザクション アイテムを取得して、ワークフロー ファイルを呼び出して、キューアイテムをInput引数として使います。
ワークフローファイル利用完了後、Mainファイルに戻してトランザクションのステータスを設定するとエラーが発生しました。
エラー内容:
トランザクションのステータスを設定: Object reference not set to an instance of an object.
エラー発生のQueueItem型変数は空ではないです。
中身:QueueItem { AssignedTo=null, DeferDate=null, DueDate=null, Id=35301608, ItemKey=[505e604f-791b-46c0-8228-97b74bdeb408], LastProcessingOn=null, Output=null, ParentOperationId=“45982a8b8f55432c9cad6c2f87cfd46b-0a5d596695ff420ba7f2c96fe62e21b6”, Priority=Normal, ProcessingException=null, Progress=“”, QueueDefinitionId=96399, QueueName=“003_TargetFactories”, Reference=“RPA依頼データフォーマット.xlsx”, RetryNo=0, ReviewStatus=“None”, RowVersion=byte[8] { 0, 0, 0, 0, 8, 175, 92, 80 }, SpecificContent=Dictionary<string, object>(3) { { “Site”, “AAA” }, { “No”, “100” } }, StartTransactionTime=[10/03/2025 12:25:58], Status=InProgress, UniqueKey=[505e604f-791b-46c0-8228-97b74bdeb408] }
UniqueKeyはOrchestratorのトランザクションアイテムと一致します。

このエラーの解決方法がございますか?

Hi, @haowen.xie When you get “Object reference not set to an instance of an object” after passing a QueueItem between workflows, it usually means the QueueItem reference was lost. Make sure to pass the QueueItem variable as an In/Out argument in your workflow, not just In. This keeps the object reference alive and should prevent that error.

@haowen.xie,

Add breakpoint before invoking sub workflow and check the value being passed to the workflow going to set status. Also check the same before set transaction status activity is any value reached till that’s step or not.

Debugging is the only way you can find the issue.

一般論ですが、このエラーの原因は変数や引数に初期値が設定されていないというエラーです。
ブレークポイントを設定して、変数や引数に初期値が設定されているかどうか確認してみてください。

こんにちは

呼び出し先のワークフローで当該キューアイテムを更新等していたりしていないでしょうか?
いずれにしましても、可能であれば、Studioでのエラー発生時のスクリーンショット等共有いただくと良いかと思います。

Hi, ashokkarale,
thank you for your reply.

Actually I tested many times and used breakpoint to check the value status.
If debug takes less time, there is no such error, if debug takes more time, there is the error.
I wondered is this a solution bug?

Hi, arjun
thank you for your reply.
Yes I checked the In/Output variables.

I get the QueueItem in main workflow and pass queueitem type variable to subflow.
I only reference to the queueitem unique values in subflow.
I also put breakpoint to check the value before change queueitem status, the value is not null.

after I tested a lot, I found in debug mode, if I checked slowly between get transaction activity and change transaction status activity, the error came out.
If I did debug fast, everything succeed.

Yoichiさん

いつもYoichiさんのコメントを拝見して開発Tipsをいただいております。今回もアドバイスをいただけましたら嬉しいです。

今回キューアイテム処理の件、
呼び出し先のワークフローでトランザクションアイテムの情報を参照するのみ、トランザクションアイテムを編集したことはないです。
エラー直前のスクリーンショットを追加しました。


キューアイテム取得からステータス変更までは約15分経ちました。
もう一回短いテストして、約8分経ってもエラーでした。

今回は3つのキュー分けて繰り返し処理を実行しています。
先週投稿した時点にエラーになっていたキューは今回、Debug実行を素早く実施したため、エラーが出てきませんでした。
一番実行時間の長いキューの方にエラーが出てきました。

よろしくお願いいたします。

このエラーは解決できました。

エラー原因:
トランザクションアイテムステータス設定アクティビティで、まず失敗ステータスへ変更して、理由は「ex_SystemException.Message」の方を作成しました。

上記アクティビティをコピーして、ステータスを「成功」へ変更します。理由欄が非表示になりましたが、理由欄に記載した「ex_SystemException.Message」が消えていないです。

このため、実行中に、ステータスを「成功」へ変更するアクティビティに、ex_SystemException.MessageがNULLのため、Object reference not set to an instance of an objectのエラーが発生しました。

解決方法:
ステータスを「失敗」へ変更して、理由欄の「ex_SystemException.Message」を手動で消してから、ステータスを再び「成功」にすると、実行してエラーがなくなりました。

以上