Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HD$

Hierarchy

  • HD$

Index

Accessors

Static InInterview

  • get InInterview(): boolean
  • Indicates whether or not the interview is currently displayed.

    Returns boolean

    Returns true if the interview is currently visible; false if not.

Static InPopupInterview

  • get InPopupInterview(): boolean
  • Indicates whether or not a popup interview is currently displayed. A popup interview is displayed when the user clicks a script link dialog element that causes additional variables or dialogs to be asked.

    Returns boolean

    Returns true if a popup interview is currently visible; false if not.

Methods

Static AttachSession

  • AttachSession(sessionID: string, serviceMetadataUrl: string, interviewOptions?: IInterviewOptions): void
  • Attaches an assembly session.

    Parameters

    • sessionID: string
    • serviceMetadataUrl: string
    • Optional interviewOptions: IInterviewOptions

    Returns void

Static CanSwitchView

  • Indicates whether or not a view (page) of the interview is available. This can be used to avoid calling SwitchView if the target view is unavailable.

    Parameters

    • viewName: InterviewPage

      The view to be displayed: Interview, AnswerSummary, DocumentPreview.

    Returns boolean

Static DetachSession

  • DetachSession(): void
  • Detaches the current assembly session.

    Returns void

Static GetInterviewBookmark

  • GetInterviewBookmark(): string
  • 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. The bookmark from this method is used as the input to the GotoInterviewBookmark method to return the user to that same location in the interview.

    If the current answer set changes between the time the bookmark is created and when it is used, the bookmark may no longer be valid. For example, if you create a bookmark to the 5th repetition of a repeated dialog, but later delete answers so there are only four repetitions, that bookmark will no longer be valid.

    var interviewOptions = {
        OnInit: function ()
        {
            HD$.RegisterHandler("PreHDSubmit",
                function (eventArgs)
                {
                    if (eventArgs.Context == "InterviewComplete")
                    {
                        var viewState = document.getElementById("__VIEWSTATE");
                        if (viewState)
                            fieldArray["__VIEWSTATE"] = viewState.value;
                    }
                    eventArgs.FieldArray["InterviewBookmark"] = HD$.GetInterviewBookmark();
                }
            );
        }
    };

    Returns string

    The requested interview bookmark.

Static GetJSONAnswers

  • GetJSONAnswers(synchronizeAnswers?: boolean): any
  • Returns the current answer set as JSON.

    Parameters

    • Optional synchronizeAnswers: boolean

    Returns any

Static GetVisibility

  • Indicates whether or not the specified interview UI element is visible.

    Parameters

    • element: InterviewElement

      The UI element to show or hide: Toolbar, AnswerSummary, DocumentPreview

    Returns boolean

Static GotoInterviewBookmark

  • GotoInterviewBookmark(bookmark: string): void
  • 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.

    If the current answer set changes between the time the bookmark is created and when it is passed into the bookmark parameter, the bookmark may no longer be valid. For example, if you create a bookmark to the 5th repetition of a repeated dialog, but later delete answers so there are only four repetitions, that bookmark will no longer be valid.

    Calling GotoInterviewBookmark with an invalid bookmark string will not have any effect.

    var interviewOptions = {
        OnInit: function ()
        {
            HD$.RegisterHandler("OnHDStart",
                function (eventArgs) { HD$.GotoInterviewBookmark('Job Information|1'); }
            );
        }
    };

    Parameters

    • bookmark: string

    Returns void

Static InvokeCommand

  • Invokes an interview command.

    • ShowHelp: Shows a help page to aid the user in completing an interview.
    • ClosePopup: Forces a modal popup interview to close.

    Parameters

    Returns void

Static OverlayAnswers

  • OverlayAnswers(answers: string): void
  • This function overlays the supplied answer JSON string over the answer set in the current interview.

    Where there is an answer in the JSON string that matches an interview variable by name and variable type, the interview variable will be updated with the new answer value. Where there is not a matching answer in the JSON, any existing answers in the interview will be unchanged.

    The supplied answer JSON must be in the correct format. For example:

    [{\"n\":\"Employee Name\",\"t\":\"TX\",\"v\":\"John Smith\"},{\"n\":\"Employee Role\",\"t\":\"TX\",\"v\":\"Engineer\"},{\"n\":\"Holiday Days\",\"t\":\"NU\",\"v\":30},{\"n\":\"Employee Date of Birth\",\"t\":\"DA\",\"v\":\"15 05 1975\"},{\"n\":\"Employee Locations\",\"t\":\"TL\",\"v\":{\"v\":[\"Aberdeen\",\"Birmingham\"]}}]

    You can get answer JSON from an interview using the GetJSONAnswers method.

    Parameters

    • answers: string

    Returns void

Static RegisterAnswerChangedEventHandler

  • Registers an event handler for an associated variable component. The handler function is called when a user changes the answer of the variable in the interview.

    Parameters

    • variableName: string
    • handlerFunc: IEventHandlerFunction

      A JavaScript function that will be called any time the event for which it is registered occurs. It should accept a single parameter, eventArgs, the contents of which are described as follows:

      PropertyDescription>
      VariableNameThe name of the variable which the interview event is linked to
      ValueThe answer(s) held for the linked variable

    Returns void

Static RegisterCustomEventHandler

  • Registers an event handler for an Interview Event Dialog Element. The handler function is called when a user clicks the dialog element's button.

    Parameters

    • eventName: string

      A string representing the name of the Interview Event Dialog Element to subscribe to.

    • handlerFunc: IEventHandlerFunction

      A JavaScript function that will be called any time the event for which it is registered occurs. It should accept a single parameter, eventArgs, the contents of which are described as follows:

      PropertyDescription>
      VariableNameThe name of the dialog element which the interview event is linked to
      ValueThe answer(s) held for the linked variable

    Returns void

Static RegisterHandler

  • RegisterHandler(eventName: APIEvent, handlerFunc: function): void
  • Registers event handlers for various interview events. If necessary the event handler can later be unregistered using the UnregisterHandler method. RegisterHandler can be used to register for the following interview events:

    • OnHDStart: This event fires when an interview is fully loaded and initialized in the browser, but before the user has a chance to interact with the interview. For example, if you want to dictate that the user should begin the interview at any dialog besides the first one, you could register for this event and call the GotoInterviewBookmark method to set an alternate starting point for the user's interview.

      The EventArgs object passed to your event handler does not have any properties.

    • OnHDNavigated: This event fires when the user navigates to a new dialog, including the dialog first displayed when starting the interview. It is fired after the dialog script has run for the new dialog, and after the display has been updated. (In the case of the first dialog, it is fired after the OnHDStart event.)

      The EventArgs object passed to your event handler has the following properties:

      PropertyDescription
      DialogNameThe name of the dialog to which the user has navigated.

    • PreHDNavigate: This event fires at the time the user attempts to navigate away from a dialog. It fires after any pending answer changes have been saved, but before focus has actually moved away from the current dialog.

      The EventArgs object passed to your event handler has the following properties:

      PropertyDescription
      DialogNameThis is the name of the dialog the user is attempting to leave.
      DialogTitleThis is the title of the dialog the user is attempting to leave. If not set in the template, it will be an empty string.
      TargetNameThis is the name of the dialog to which the user is attempting to navigate.
      TargetTitleThis is the title of the dialog the user is attempting to navigate. If not set in the template, it will be an empty string.
      Cancel If you set this Boolean property to true, the user's attempt to navigate away from the dialog will be cancelled.

      Caution: If you cancel the user’s navigation, it is strongly recommended that you supply a CancelMessage. If you do not, you should undertake some other means of communicating to the user why they are not being allowed to navigate away from the current dialog.

      CancelMessageIf navigation was cancelled and this property is a non-empty string, a message box is displayed to the user to indicate why navigation was cancelled.

    • OnHDFinish: This event fires when the user clicks the Finish button, after HotDocs first ensures that all required variables have been answered. You can use this function to perform custom answer validation and potentially cancel the user's action if needed.

      The EventArgs object when this event is called has the following properties:

      PropertyDescription
      CancelIf you set this Boolean property to true, the user's attempt to finish the interview will be cancelled, leaving them at the current dialog.
      CancelMessage If navigation was cancelled and this property is a non-empty string, a message box is displayed to the user to indicate why navigation was cancelled.

      Caution: If you cancel the user’s navigation, it is strongly recommended that you supply a CancelMessage. If you do not, you should undertake some other means of communicating to the user why they are not being allowed to navigate away from the current dialog.

    • PreHDSubmit: This event fires immediately before the assembly request is sent to the server when the user clicks the Finish button.

      The EventArgs object when this event is called has the following properties:

      PropertyDescription
      Context A string indicating the context in which the event handler was called. It can be one of the following values:
      • InterviewComplete: The user clicked either the Finish button or the Next button at the last dialog.

    • OnHDProgress: This event fires every time a variable is answered (or cleared) or the interview content otherwise changes, such that information about the user's progress towards completion of the interview has changed. You might use this event if you have suppressed display of the built-in interview progress bar (using the HDInterviewOptions.ProgressBar option) and wish to track user progress through some alternate means.

      The EventArgs object when this event is called has the following properties:

      PropertyDescription
      AnsweredThe number of answered questions, not counting answers to optional questions
      TotalThe total number of questions in the interview (not counting optional questions)
      State A number indicating the state of the interview as a whole.
      • 0: Interview is complete. If the interview progress bar were visible and had the default styling applied, this would correspond to a green, fully complete progress bar.
      • 1: Interview is incomplete. If the interview progress bar were visible and had the default styling applied, this would correspond to a blue progress bar in an empty or partially-complete state.
      • 2: Interview is incomplete, and one or more of the unanswered questions are required before the user is allowed to progress further. If the interview progress bar were visible and had the default styling applied, this is one of two states that would display a red progress bar.
      • 3: The interview contains a dialog with an error message, which prevents the user from progressing. If the interview progress bar were visible and had the default styling applied, this is one of two states that would display a red progress bar.
      • 4: The interview is incomplete, there is one or more required unanswered question, and a dialog contains an error message. Because of this state, the user cannot progress further in the interview. If the interview progress bar were visible and had the default styling applied, this is one of two states that would display a red progress bar.

    • OnSessionComplete: This event fires when an assembly session is finished.

      The EventArgs object passed to your event handler has the following properties:

      PropertyDescription
      CancelIf you set this Boolean property to true, the session completion dialog will not be displayed.
      CancelMessageIf the dialog display was cancelled and this property is a non-empty string, a message box is displayed to the user with this string instead.

    • OnStateSaved: This event fires when the interview successfully saves its state to the Assembly Service

      There are no event args for this event

    • OnInterviewUnload: This event fires when the interview is unloaded by the browser. e.g. Page/tab closing, browser back button, clicking on a hyperlink, etc.

      There are no event args for this event

    Parameters

    • eventName: APIEvent

      A string representing the name of an interview event. You can specify any string, but only valid APIEvent strings are supported and will cause your event handler to be called.

    • handlerFunc: function

      A JavaScript function that will be called any time the event for which it is registered occurs. It should accept a single parameter, EventArgs, the contents of which vary depending on the event.

        • (eventArgs: any): any
        • Parameters

          • eventArgs: any

          Returns any

    Returns void

Static SaveAnswers

  • SaveAnswers(callback?: function): void
  • Save the interview answers. If you provide a callback function, it will be called when the save is complete. Note: the interview automatically saves answers as users navigate through the interview. You are never required to call this function. It is made available so that you can force an answer save if necessary.

    Parameters

    • Optional callback: function
        • (): void
        • Returns void

    Returns void

Static SetVisibility

  • Show or hide parts of the interview user interface.

    Parameters

    • element: InterviewElement

      The UI element to show or hide: Toolbar, AnswerSummary, DocumentPreview

    • isVisible: boolean

      Indicates whether the element should be shown or hidden.

    Returns void

Static ShowMessageBox

  • ShowMessageBox(message: string, caption?: string, icon?: string, allowPrint?: boolean): any
  • Shows a modal message box.

    Parameters

    • message: string

      The string of text you wish to display on the message box.

    • Optional caption: string

      The string of text you wish to display in the message box's title bar.

    • Optional icon: string

      The CSS class name of the icon to display in the title bar (by default, it is 'hd-alert').

    • Optional allowPrint: boolean

      Displays a Print button on the message box for printing its contents. (Default is false)

    Returns any

Static SwitchView

  • Switch between Interview, Answer Summary, and Document Preview views of the interview.

    Parameters

    • viewName: InterviewPage

      The view to be displayed: Interview, AnswerSummary, DocumentPreview.

    Returns void

Static UnregisterHandler

  • UnregisterHandler(eventName: APIEvent, handlerFunc: function): void
  • Unregisters an event handler for an interview event that was previously registered using the RegisterHandler method.

    Parameters

    • eventName: APIEvent

      A string representing the name of an interview event. You should specify the same string you used when registering the event handler.

    • handlerFunc: function

      The JavaScript function that was registered as an event handler, which you would like to unregister.

        • (eventArgs: any): any
        • Parameters

          • eventArgs: any

          Returns any

    Returns void