Hi
The error was shown in the dialog box while running the script as:
<function GetMessages at 0x000002F1582FCAE8>
I don't know how to use traeback...
Anyway, I found the syntax error in the code. The return = 'OFF' within single quotes in the elif statment should be return = "OFF" within double-quotes. Silly but it took some time to figure out where the problem was from, among variables, codeblock, logic...
codeblock_source = """def getSource(elev,user_source,source,ons_off):
if elev != -9999 and ons_off == 'Onshore' and source == 'NA':
return user_source
elif ons_off == 'Offshore':
return "OFF"
else:
return source"""
It all works now! And it does mean there are some subtle difference in Python in ArcGIS Desktop and ArcGIS PRO...