Using the Javascript tab, you can write Java code using the available predefined functions, script data, and agent parameters created for the script to function. The following section describes the use of certain script functions that appear in the Functions area of the JavaScript tab.

Functions

This section describes the Java functions used for buttons or custom JavaScript code that perform specific actions when triggered. All methods must be accessed with the prefix “lvcore.” For example, lvcore.getAccountNumber(); returns the account number of the current call. The main functions are categorized as follows:

This section contains functions that help in managing calls and conference APIs.

Function NameDescriptionParameters

lvcore.completeConference()

An agent uses this function to complete a conference call, bringing all three parties, the agent, caller, and supervisor, onto the same call.-
lvcore.leaveConference()This function is used by an agent to leave a conference call, allowing the supervisor and caller to continue on the call while the agent is disconnected.-
lvcore.reconnectCall()This function is used by an agent to reconnect with a caller, returning the call to the state it was in before the agent attempted to transfer it.-
lvcore.transferCall(phone, extension, delay, secure)This function transfers a call to a specified phone number or extension with optional parameters for delay and security.
  • phone: The phone number to which the call is being transferred.
  • extension: The extension number to which the call is transferred (if applicable).
  • delay: An optional delay (in seconds) before the transfer is executed.
  • secure: A Boolean parameter that, when set to true, ensures the transfer is handled securely.

phone, extension, delay, secure

lvcore.setPendingStatus(ready,breakCode)This function updates the agent's status to a pending state with an optional break code.
  • ready: A Boolean parameter indicating whether the agent is ready to take calls (true) or not (false).
  • breakCode: An optional code specifies the reason for the pending status or break.
    The valid values include:
    • Break
    • Lunch
    • Meeting
    • Other
This function allows the agent’s status to be set to a pending state, reflecting their availability and providing a reason for the status change if applicable.

ready,breakCode

This section contains functions that help in managing credit card transactions.

Function Name

Description

Parameters

lvcore.getSecureCreditCard(scriptDataHolder, showAlert)

This function is used to securely retrieve a credit card number within a script.

  • scriptDataHolder: This parameter holds the data related to the current script session, including information needed to retrieve the credit card number.

  • showAlert: A Boolean parameter that, when set to true, triggers an alert message to confirm or notify the agent that the credit card number has been retrieved securely.

This function ensures that sensitive information, such as credit card details, is handled securely during the interaction.

scriptDataHolder, showAlert

lvcore.getSecureExpiryDate(scriptDataHolder, showAlert)

This function is used to securely retrieve the expiration date of a credit card within a script.

  • scriptDataHolder: This parameter stores the data related to the current script session, including the information necessary to retrieve the credit card's expiration date.

  • showAlert: A Boolean parameter that, when set to true, displays an alert message to confirm or notify the agent that the expiration date has been securely retrieved.

This function ensures that the credit card's expiration date is handled securely during the interaction.

scriptDataHolder, showAlert

lvcore.getSecureCode(scriptDataHolder, showAlert)

This function is used to securely retrieve a credit card's security code (CVV) within a script.

  • scriptDataHolder: This parameter contains the data related to the current script session, which includes the information needed to retrieve the security code.

  • showAlert: A Boolean parameter that, when set to true, triggers an alert message to notify the agent that the security code has been securely retrieved.

This function ensures that the security code is accessed and handled securely during the interaction.

scriptDataHolder, showAlert

lvcore.initiatePaymentProcessing()

This function starts the payment processing workflow within a script. This function typically initiates the payment transactions, including validating and submitting payment details for processing.

-

lvcore.checkCreditCardField(fieldName)

This function validates the specified credit card field within the script.

  • fieldName: The name of the credit card field to be checked (for example, credit card number, expiry date, CVV).

This function ensures that the specified field meets the required format and validation criteria for processing.

fieldName

lvcore.checkCreditCard(cardnumber)

TThis function verifies the validity of a provided credit card number.

  • cardnumber: The credit card number to be checked.

This function validates the format and authenticity of the credit card number to ensure it meets the required standards for processing.

cardnumber

lvcore.getCardType(creditCardNumber)

This function determines the type of credit card based on the provided credit card number.

  • creditCardNumber: The credit card number for which the type is being identified.

This function identifies the card type (for example, Visa, MasterCard, American Express) by analyzing the number's format and issuing bank identifiers.

creditCardNumber

This section contains functions that help in managing core functions.

Function Name

DescriptionParameter

lvcore.checkRequiredFields()

This function validates HTML fields to ensure that they meet the necessary criteria.
  • Required Fields: Ensures all mandatory fields are filled.
  • Regex: Validates fields against specified regular expressions to ensure the correct format.
  • Matching Elements: Checks that fields requiring matching values (for example, password confirmation) are consistent.

This function helps ensure that all relevant data is correctly entered and formatted before proceeding.

-
lvcore.getFormData()

This function retrieves the data entered in a form within the script.

This function collects and returns all input values from the form fields, allowing for further processing or validation of the submitted data.

-
lvcore.setFormData()This function populates all user interface (UI) controls with data from the formData variable.-
lvcore.validateField(element, focus, forceMatching)

This function is used to validate a form field based on several criteria.

  • element: The form field (or element) to be validated.
  • focus: A Boolean parameter that, when set to true, sets focus on the field if validation fails, prompting the you to correct the input.
  • forceMatching: A Boolean parameter that, when set to true, enforces the field's value to match another specified field (for example, password confirmation).

This function ensures that the field meets validation rules, such as correct format, required value, or matching another field, and can optionally focus on the field if it does not pass validation.

element, focus, forceMatching
lvcore.fireApiRequest(apiName, requestName)

This function initiates an API request within the script or application.

  • apiName: The name of the API with which you want to interact.
  • requestName: The specific request or action to be performed with the API.

This function triggers the specified API call, allowing you to execute operations or retrieve data from an external service or system based on the provided parameters.

apiName, requestName
lvcore.validateAddress(scriptDataName,value)

This function validates an address field within the script.

  • scriptDataName: The name or identifier of the address field to be validated.
  • Value: The address value to be checked.

This function ensures that the provided address meets the necessary format and validation criteria, specifically for US postal addresses. It helps to verify the accuracy and completeness of address data within the script.

scriptDataName,value

This section contains functions that help in managing the get functions.

Function Name

DescriptionParameter

lvcore.getAccountNumber()

This function retrieves the account number associated with the current call or session. This function accesses the customer's account number to process or display it within the script or application.

-
lvcore.getAgentInfo()This function retrieves information about the current agent, such as their ID, name, or other relevant details.-
lvcore.getCallSessionId()

This function retrieves the session ID for the current call.

-
lvcore.getOriginalAgentInfo()This function retrieves information about the original agent who first handled the call or session.-
lvcore.getScriptSessionId()

This function retrieves the unique session ID for the current script session.

This ID is used to track and manage the script session, ensuring that all actions, data, and interactions within the session are properly logged and associated with the correct instance of the script.

-
lvcore.getScriptData(key)

This function retrieves specific data from the current script session using a provided key.

  • key: The identifier or name associated with the data you want to retrieve.

This function allows you to access and use specific pieces of data stored in the script session, facilitating data retrieval and manipulation based on the given key.

key

This section contains functions that help manage the main functions.

Function Name

DescriptionParameter

selectContactCallback(contact)

This function is a callback function that processes a selected contact.

  • contact: The contact object or data passed to the callback function typically includes details about the selected contact.

This function handles actions or logic that should occur once a contact has been selected, such as updating UI elements, initiating further interactions, or processing contact details.

contact

This section contains functions that help manage the Navigation functions. 

Function Name

DescriptionParameter

lvcore.endScriptWithTermCode(lvResultId, agentAccountNumber, notReadyPrompt, paymentAmt)

This function is used to terminate a script session and write the associated data to the database.

lvResultId, agentAccountNumber, notReadyPrompt, and paymentAmt

lvcore.previousPage()

This function navigates the user back to the previous page they were on in the script or application.

This function is useful for allowing users to easily return to the last page they visited, facilitating smooth navigation and improving user experience.

-

lvcore.goToPage(pageName)

This function navigates the user to a specified page within the script or application.

  • pageName: The name or identifier of the page to which you want to navigate.

This function allows for seamless transitions between different pages in the interface, directing you to the desired page based on the provided pageName.

pageName

This section contains functions that help manage the Update functions. 

Function Name

DescriptionParameter

lvcore.changeContact(contactNumber, successCallback, failureCallback, eventsOnRefresh)

This function changes the contact information associated with a script or application.

  • contactNumber: The new contact number to be updated.
  • successCallback: A callback function to be executed if the contact update is successful.
  • failureCallback: A callback function to be executed if the contact update fails.
  • eventsOnRefresh: A Boolean parameter that, when set to true, triggers any associated events or actions upon successfully updating the contact.

This function facilitates updating contact details while handling success and failure scenarios, and refreshes associated events or actions accordingly.

contactNumber, successCallback, failureCallback, eventsOnRefresh

lvcore.updateScriptData(scriptDataName, value, mask)

This function updates or creates a Script Data variable within the script session.

  • scriptDataName: The name of the Script Data variable to be updated or created, specified as a string (for example, "VariableName").
  • value: The new value to be assigned to the Script Data variable. This can be a specific value or a variable.
  • mask: An optional parameter determining whether the value should be masked (for example, for sensitive information) or left unmasked.

This function allows you to update existing Script Data or create new Script Data variables within the session. If the mask parameter is used, it ensures that sensitive data is handled appropriately. The function also prints the updated value to the console for tracking purposes.

scriptDataName, value, mask

lvcore.updateScriptDataAll()

This function updates all Script Data variables within the script session with their current values.

This function ensures that any changes to Script Data variables are applied across the entire script session, maintaining consistency and reflecting the latest data for all relevant variables.

-

lvcore.updateContact()

This function updates the contact information associated with the current script or application.-

lvcore.updateAccountNumberLegacy(contactNumber)

This function updates the account number associated with a contact using a legacy system in an inbound service.

  • contactNumber: The new contact number is to be set as the account number.

This function updates the account information in systems that use older or legacy data formats, ensuring that the account number is accurately updated based on the provided contact number. The contactNumber parameter sets that contact as the new active contact in the script session. However, it does not reload the page, so nothing in the scripter form is updated.

This function is intended to be used only in specific scenarios where backward compatibility with older systems is required.

contactNumber

This section contains functions that help manage the utility functions. 

Function Name

DescriptionParameter

lvcore.getFormElementById(elementId)

This function retrieves a specific form element using its identifier.

  • elementId: The unique identifier of the form element you want to access.

This function lets you interact directly with a particular form element, enabling operations, such as reading its value, setting properties, or manipulating its state based on its ID.

elementId

lvcore.lvalert(msg)

 This function displays an alert message to the user.
  • msg: The message text to be shown in the alert.

This function is used to provide notifications or warnings through a pop-up alert

-msg

lvcore.showItem(elementId)

This function makes a specified UI element visible on the page.

  • elementId: The identifier of the element you want to display.

This function is useful for dynamically controlling the visibility of elements, allowing you to show certain UI components based on user actions or script conditions.

elementId

lvcore.hideItem(elementId)

This function makes a specified UI element hidden on the page.

  • elementId: The identifier of the element you want to hide.

This function is useful for dynamically controlling the visibility of elements, allowing you to remove certain UI components based on user actions or script conditions.

elementId

lvcore.mask(text)

This function is used to mask data or information.text

lvcore.unmask()

This function is used to unmask the data or information-