blocking warehouse transfer to specific location

I needed to block users transferring items to specific location using transfer order.Using the following code OnIsertRecord() page event but not working. IF (“Transfer-from Code”=‘FG-WHS-xxx’) AND (“Transfer-to Code”=‘PF-WHS-xxx’) THEN ERROR(‘xxxx’);blocking warehouse transfer to specific location

OnInsertRecord() is triggered only when the records get inserted into the table, i.e when the Key fields are entered. In this case Transfer-from Code and Transfer-to Code are not part of keys for the Table Transfer Header. You can put the code in the OnValidate() Trigger of both the fields.