watsonx Orchestrate

 View Only

 About a python code in Code block

Himasha Semage's profile image
Himasha Semage posted Mon January 05, 2026 05:09 AM

Following is my current python code that I have used:
"packageMobile = None
if flow["User activity 2"].Packages.output.value:
packageMobile = flow["User activity 2"].Packages.output.value
elif flow["User activity 3"].Packages.output.value:
packageMobile = flow["User activity 3"].Packages.output.value
elif flow["User activity 4"].Packages.output.value:
packageMobile = flow["User activity 4"].Packages.output.value
elif flow["User activity 5"].Packages.output.value:
packageMobile = flow["User activity 5"].Packages.output.value
elif flow["User activity 6"].Packages.output.value:
packageMobile = flow["User activity 6"].Packages.output.value
elif flow["User activity 7"].Packages.output.value:
packageMobile = flow["User activity 7"].Packages.output.value
elif flow["User activity 8"].Packages.output.value:
packageMobile = flow["User activity 8"].Packages.output.value
elif flow["User activity 9"].Packages.output.value:
packageMobile = flow["User activity 9"].Packages.output.value
elif flow["User activity 10"].Packages.output.value:
packageMobile = flow["User activity 10"].Packages.output.value
elif flow["User activity 11"].Packages.output.value:
packageMobile = flow["User activity 11"].Packages.output.value
elif flow["User activity 12"].Packages.output.value:
packageMobile = flow["User activity 12"].Packages.output.value
elif flow["User activity 13"].Packages.output.value:
packageMobile = flow["User activity 13"].Packages.output.value
else:
packageMobile = "No paccckage selected"

self.output.packageMobile = packageMobile"

Output values are from single choice option. In here I want to display the user's choice. But current it shows something else (Screenshot 01). In Screenshot 02, I have provided the defined output of the code block and in Screenshot 03 I have given how I have define the message that I want to display to the user.
Can I know why the value of the choice in single choice option is not shown and something else is displayed to the user.
I have provided the screenshot mentioned above.

Dennis Parrott's profile image
Dennis Parrott

Hi Himasha, I'm reviewing this issue and I'd like to understand the end-to-end flow. It looks like you may have a branch that goes to each of the user activities. If each of the user activities are identical apart from the single choice selection then you can implement this using a single user activity, with logic before the user activity to define the appropriate list of choices. Alternatively, if you want multiple user activities, then you can simple add a code block after each user activity to assign the output to the flow variable.

Himasha Semage's profile image
Himasha Semage

Hi @Dennis Parrott, each user activity is going based on different condition. Like initially, the user is going to enter some information like the plan preferred, budget and the purpose. So, based on the user selection then only it will direct to the related user activity.  

Attachment  View in library