Sales Order # on Delivery Note

I would like to print Sales Order number on the Delivery Note. It will printed only when the delivery is related to any sales order.

How to do that?

BR/Mijan

Follow the solution in this post.

However, I did not include anything in the Depends On field even though the original poster suggests var1 = frm.doc.{against_sales_order} and another person suggests var1 = frm.doc.{fieldname}.

After creating the Custom Script in the solution, just go to Print Format Builder and add So No wherever you wish.