JavaScript Library
XM Solutions can make use of a pre-built JavaScript library that provides functions to expedite the process of making transformations to Qualtrics resources.
If you would like to join the early access program for XM Solution Plugins, then please let us know by taking this survey.
This feature is in Early Access and is not yet generally available. Functionality, APIs, and documentation may change before general availability.
Here's a list of the available functions and how to import them for each resource type as of version 0.0.27.
General Functions
There are some resource-agnostic functions that are available to use in resource transformation as well as unit testing. These functions can be imported from "@qualtrics/solution-utils".
-
interpolate(resource, context): finds strings of the format{{ $.path.to.context.variable }}and replaces them with the context variable whose path is specified in the string to be replaced. If the path provided does not exist on the context, then it will be replaced with the empty string. -
deepCopy(object): copy an object or array and then return that copy. This is useful for unit testing, specifically for making additional context or resource objects to make changes and fully test the alternative situations caused by input.
Survey Functions
These functions are meant for to be used on survey resources. They can be imported from "@qualtrics/solution-utils/survey".
-
removeQuestion(survey, questionID): removes a specific question from the provided survey resource and modifies the resource in-place. Uses the internal question ID, which is formatted like this:QID1 -
removeQuestionAndPageBreak(survey, questionID, pageBreakAfter): removes a specific question and a page break from the provided survey resource and modifies the resource in-place. Uses the internal question ID, which is formatted like this:QID1, and will remove a page break before the question unlesspageBreakAfteristrue. -
removeBlock(survey, blockID, flowID): removes a specific block from the provided survey resource and modifies the resource in-place. If a block ID (BL_4Yl5udJ8kfiV4b4) is provided, it will remove the block from the blocks section and editor. If a flow ID (FL_3) is provided, it will remove the block from the survey flow, which will prevent it from being shown to respondents.
Printed Report Functions
These functions are meant to be used on printed report resources. They can be imported from "@qualtrics/solution-utils/printed-report".
-
removeWidget(printed-report, widgetID): removes a specific widget from the provided printed-report resource and modifies the resource in-place. Uses the widget ID, which is formatted like this:Widget_0f5f2829-f133-4666-82a2-a781b8faf5a5 -
removePage(printed-report, pageID): removes a page from the printed-report resource as well as all widgets on that page and modifies the resource in-place. Uses the page ID, which is formatted like this:Page_dc4bcb13-159e-4d06-b4ec-447a6cb1a1db
Dashboard Resource Functions
These functions are meant for to be used on dashboard resources, including the fieldset, the sourcemap, and the CXDashboard.
Fieldset Functions
The fieldset functions can be imported from "@qualtrics/solution-utils/fieldset".
removeField(fieldset, fieldID): removes a specific field from the fieldset resource and modifies the resource in-place. Uses the field ID, which can reference a question ID (QID14,QID3_TEXT, orQID6_1depending on the type of question) or an embedded data field name (recipientFirstName).
Sourcemap Functions
The sourcemap functions can be imported from "@qualtrics/solution-utils/sourcemap".
removeMapping(sourcemap, mapID): removes a specific mapping from the sourcemap resource and modifies the resource in-place. Uses the map ID, which can reference a question ID (QID14,QID3_TEXT, orQID6_1depending on the type of question) or an embedded data field name (recipientFirstName). The map ID will also match the field ID in the fieldset.
CXDashboard Functions
The CXDashboard functions can be imported from "@qualtrics/solution-utils/cxdashboard".
-
removeWidget(cxdashboard, widgetID): removes a specific widget from the provided CXDashboard resource and modifies the resource in-place. Uses the widget ID, which is formatted like this:Widget_0f5f2829-f133-4666-82a2-a781b8faf5a5 -
changeWidgetTitle(cxdashboard, widgetID, newTitle): changes the title of a specific widget in the provided CXDashboard resource and modifies the resource in-place. Uses the widget ID, which is formatted like this:Widget_0f5f2829-f133-4666-82a2-a781b8faf5a5, andnewTitleis the string you want to be the title of the widget. -
removePage(cxdashboard, pageID): removes a page from the CXDashboard resource as well as all widgets on that page and modifies the resource in-place. Uses the page ID, which is formatted like this:Page_dc4bcb13-159e-4d06-b4ec-447a6cb1a1db