Show task in interface which matches the order Id criteria

Certified Associate Developer

Hi All,

I was trying to show tasks related to the order  in that order details interface, I was trying to write code but most of the time it comes half baked.

I would like your help in this case. I understand I need to use looping, indexing and if condition to get this done , But I was not able to get the correct form of logic.  If any sample code is available for this scenario is very helpful for me to understand.

Thanks in Advance

for example(The desired outcome), below for an order it is showing approval task related to that order:

  Discussion posts and replies are publicly visible