Skip to main content
All CollectionsExamples & Tutorials
Conditionally show question based on the response to a SharePoint drop-down
Conditionally show question based on the response to a SharePoint drop-down

Lets looks at an example of conditionally showing a question based on the response to a SharePoint drop down

Updated over 2 months ago

In this article we will demonstrate how to use conditional logic to hide and show a question based on the answer to a SharePoint drop-down menu. In our example, we have a drop-down menu that contains a list of countries from an Excel Online document. If the chosen country is Australia we need to display a textbox to enter an Australian Business Number (ABN).

To create conditionals based on a SharePoint data source we will need to use advanced conditionals using javascript. In javascript we can use the data variable to access the answer to any of the fields, however it is first important to understand how SharePoint information is stored inside the data variable. Unlike some of the simpler components (like a textbox) the answer is not simply stored as text, instead all columns/fields are stored as a JSON object. This is shown in the image below.

ℹ️ Tip: you can use the "Show Submission Data" button on the preview screen to view the entire data object

From the image above we can see that each column of the data source is stored in its own field under the countries object. Therefore in our conditional formula we need to reference down to the specific column/field as show below.

show = date['countries']['Country] === 'Australia'

Simply open the component settings for the field you want to hide/show, navigate to the conditional tab and write an expression in the Advanced Conditions setting.

Did this answer your question?