HDAPI Object
HDAPI encapsulates methods for interacting (at runtime) with HotDocs browser interviews running in a frame or window to which you have direct access to the scripting environment. This API can be used for anything from getting or setting answers entered by the user, to customizing the commands available to the user, to detecting and acting on certain user actions.

JavaScript API: Direct
Assembly: api.js Version: (

Direct.HDAPI = function();


The HDAPI type exposes the following members.


Public methodAddCustomNavButton
This function adds a button to the interview navigation bar. When a user clicks the button, a JavaScript function is called that performs any action users may need to take while navigating through the interview.
Public methodCode exampleAddCustomToolbarButton
This function adds a button to the interview toolbar. When a user clicks the button, a JavaScript function is called that performs any action you may wish to make available to users of your host application, such as displaying your host application's help file.
Public methodClosePopupInterview
This function forces the modal popup interview to close.
Public methodDocumentPreview
Posts answers to the server and displays the response (an HTML or PDF rendition of the assembled document) in the document preview pane.
Public methodEncodeString
Base64-encodes a string of text. Supports internal encoding in UTF-8 or UTF-16.
Public methodGetAnswer
This function gets the answer value for a variable. It can also get a single (indexed) value from a repeated answer.
Public methodGetAnswerIterator
This function returns a single number value that represents the repeat index (1-based) of the current dialog. This is different than HDAPI.GetAnswerRepeatIndex, which is 0-based and returns a complete set of four indexes. As such, GetAnswerIterator is most useful for non-nested repeats where there is only one index that matters.
Public methodCode exampleGetAnswerRepeatIndex
This function returns the full set of repeat indexes for the current dialog. When using HDAPI.GetAnswer and HDAPI.SetAnswer with repeated dialogs, this function allows you to get or set the values of variables in the current repetition.
Public methodGetAnswerSummary
Returns a summary of answers from the interview in HTML format.
Public methodCode exampleGetInterviewBookmark
This function returns a string (up to 70 characters in length) that represents the user's current location in the interview, including the input field that contains the focus. For example, you can call this function from your handler for the PreHDSubmit event, in order to submit a bookmark for the user's current location to the server along with the user's answers. Later, you would use the HDAPI.GotoInterviewBookmark function to return the user to that same location in the interview.
Public methodGetProgress
This function returns an object containing information about the user's progress in the current interview.
Public methodGetXMLAnswers
This function returns an XML string of answers from the current interview. For example, you could use this string to overlay the current interview's answers on top of an existing answer file, thus updating the answer file with any answers that have been entered during the interview.
Public methodCode exampleGotoInterviewBookmark
This function navigates the user to a specific dialog in the interview, and moves the focus to a designated field within that dialog. If the bookmark is invalid, or the location is no longer part of the interview, no navigation takes place.
Public methodInPopupInterview
This function returns a value indicating whether or not a popup interview is currently displayed.
Public methodInvokeButton
This method invokes the 'OnClick' function for one of the toolbar or navigation bar buttons (either built-in or custom), even if the button has been hidden. For example, if you create your own "Finish" button, you may want to hide the built-in "Finish" button but still have your custom button perform the same action by invoking the 'OnClick' function for the hidden "Finish" button.
Public methodPostAnswersToServer
This function posts the current answer collection from the interview to the server. The browser interview calls this function internally when the user clicks the Save Answers button during the interview. It may also be invoked from 3rd party code, if (during the course of an interview) you need to post the current answer set to some URL and (optionally) display a server-returned response to the user.
Public methodPostToServer
This method posts information to the server. It is used by the HDAPI.PostAnswersToServer method for posting answers to the server, but you could use it to post any other kind of information. For example, if your host application can generate some sort of custom summary page, this function could post data to that page and display the response to the user (in the context of the intervew).
Public methodRegisterHandler
This function is used to register event handlers for various interview events. They can be used for both JavaScript and Silverlight interviews. If necessary the event handler can later be unregistered using the HDAPI.UnregisterHandler function.
Public methodCode exampleScreenRefresh
This function refreshes the screen to update answers in the variable fields that have changed.
Public methodServerResponseVisible
This function returns a value indicating whether or not the modal server response is currently visible or not. If the server response is visible, all the input fields of the interview are currently obscured and unavailable for interaction, and other API functions (such as InvokeButton) will not function.
Public methodSetAnswer
This function sets the answer value for a variable. It can also set a single (indexed) value in a repeated answer.
Public methodCode exampleSetButtonVisibility
This function lets callers hide individual buttons on the toolbar or navigation bar. It can also be used to hide the entire toolbar or navigation bar.
Public methodSetNavbarButtonImage
This function sets the image to use for navigation bar buttons.
Public methodSetTemplateTitle
This function sets the template title that appears in the toolbar.
Public methodSetToolbarButtonImage
This function lets callers specify alternate images for built-in toolbar buttons. It should be called before the toolbar is rendered for the first time, such as in the HDInterviewOptions.OnInit method.
Public methodShowMessageBox
This function shows a modal message box.
Public methodUnregisterHandler
This function is used to unregister an event handler for an interview event that was previously registered using the HDAPI.RegisterHandler function.

Beginning with HotDocs Server 11 (and HotDocs Cloud Services), the HDAPI object is the recommended means of integrating with a HotDocs browser interview (from JavaScript in the host page). The global functions present in prior versions of HotDocs Server are still present for backwards compatibility, but they have been deprecated.
See Also