# Appendix B -- Debugging
GENERAL
Domino Designer is equipped with a powerful debugging tool to debug your LotusScript code. Wherever possible, consider first putting your code in a Notes client button and verify the code there before executing it from an agent.
Your application specific code. Application specific code to be executed when a workflow document is either opened or when the Send button is selected by the user should be referenced in the appropriate place in the State documents and defined in script library WA Application Specific (the calls to which to be included in subroutine waExecuteStoredProcedure). These subroutines can update document data and/or block a document from advancing in the workflow. All such code is executed via agents (waInitializeWorkflowEngine) and (waInitializeWorkflowEngine). Should you need to pass arguments to these routines, use designated fields to that effect in the workflow document.
Computed Form field values. Computed formulas and default values will take effect as the computeWithForm option is set to both (referring to the onload and onsave events) in XPage Document# by default.
(waInitializeWorkflowEngine). This LotusScript agent is launched from the XPage Document# beforePageLoad event. This agent in turn calls the PostOpenDoc (WA Workflow script library) which in turn executes any routines you have referenced in the State documents and defined in script library WA Application Specific (the calls to which to be included in subroutine waExecuteStoredProcedure).
(waRunWorkflowEngine). This LotusScript agent is launched from the XPage Document# postSaveDocument event. This agent in turn calls routines you have referenced in the State documents and defined in script library WA Application Specific (the calls to which must be included in subroutine waExecuteStoredProcedure).
Workflow Ascendant is equipped with a complete set of logging features. Provided you have configured the log correctly (creating the Agent Log database and referencing it in the active Language document), you can put the following command in your application specific code in order to view variables / field values in the log:
Call a_LogWrite( "Got Here" )
Call a_LogWrite( doc.MyField( 0 ))
Etc.
JAVASCRIPT
This will concern any specific transactions that take place within the context of a given state. Workflow Ascendant largely limits the usage of javascript to pulling values from the XPage and passing them on to LotusScript agents. Should you use that approach, the a_LogWrite command can first be used to verify that you're getting the values correctly into your agent. For any debugging to be done prior to (or after) that, you can use the following command to output variables to the Domino console:
print("Got Here")
There are also downloadable tools available on the web to display scoped variables.