Import Scripts are a powerful tool, but debugging long scripts can become a chore!
💡 HINT: You can help your future self by including comments in your scripts. Comments sit on a line alone, preceded by a double-hash - e.g.:
## This is a comment
The 'Debug' mode on Imports can help by 'recording' how the script processed a particular import. You can turn on Debug mode under Advanced on the Import screen.
⚠️ WARNING: Turning on debugging can significantly impact performance - do NOT leave it on permanently on a live system!
When an import is run with Debug mode enabled, the system 'records' script execution. To view the 'recording' for a particular payment, identify the payment in question (you can just do a normal payment search) and drill into the 'Details' section, where you will see a ladybird 'Debug' button next to the File Name.
You can then drill into the Debug record itself, which contains 3 key sections.
In
This shows the state of every field BEFORE the script ran.
Out
This shows the state of every field AFTER the script ran.
Script 'Playback'
The bottom half of the screen shows a 'Playback' of the script run, with executed lines highlighted in yellow.
💡 HINT: The value of a field can change during script execution - this can impact the behaviour of your #IF statements.
To take an example, assuming the 'In' value of Ref1 was '1234', the second half of the following script would NOT run, because at the time of the execution of the second #IF the value is no longer '1234':
#IF data['Ref1'] == '1234'
data['Ref1'] = 'CT1234'
#END IF
#IF data['Ref1'] == '1234'
data['FundCode'] = '01'
#END IF