Fetching an IBAN from a Bank Account to a custom field in the Purchase Order DocType

In some cases we need to print out the IBAN number of the Supplier to a custom Purchase Order document.

To achieve that, I’ve added two custom fields to the Purchase Order DocType:

  • pay_to - This is a link to the supplier of the Purchase Order bank account, and needs to be selected manually.
  • iban - This field should be auto-populated with the value of the iban-field in the selected supplier bank account from the pay_to field.

I’ve tried server and client-side scripts but I’m always encountering sql-errors…

So if somebody could help me out how to automatically fetch the iban number that would be great…