This article explains how to:
Part 1: Using a View Query
Step 1: Get the View Query by View Name
Use the following REST API: SITEURL/_api/web/lists/getbytitle('LISTNAME')/views/getbytitle('VIEWNAME')?$select=ViewQuery
In the response, locate the d:ViewQuery element.
Example:
<d:ViewQuery>
<Where>
<Eq>
<FieldRef Name="Business" />
<Value Type="Text">Global Audit &amp; Assurance</Value>
</Eq>
</Where>
</d:ViewQuery>
Step 2: Extract the ViewQuery Value
Find the content inside:
<d:ViewQuery> ... </d:ViewQuery>
Step 3: Format the View XML
a. Decode the XML
Use any online XML decode tool.
After decoding, you should get:
<Where>
<Eq>
<FieldRef Name="Business" />
<Value Type="Text">Global Audit & Assurance</Value>
</Eq>
</Where>
b. Wrap with <View><Query>
Replace:
<d:ViewQuery> with <View><Query></d:ViewQuery> with </Query></View>
Result:
<View>
<Query>
<Where>
<Eq>
<FieldRef Name="Business" />
<Value Type="Text">Global Audit & Assurance</Value>
</Eq>
</Where>
</Query>
</View>
c. Replace Double Quotes with Single Quotes
Final XML:
<View><Query><Where><Eq><FieldRef Name='Business' /><Value Type='Text'>Global Audit & Assurance</Value></Eq></Where></Query></View>
Step 4: Create the JSON Body
Use the following format:
{
"query": {
"ViewXml": "VIEWXML"
}
}
Replace VIEWXML with your formatted XML.
{
"query": {
"ViewXml": "<View><Query><Where><Eq><FieldRef Name='Business' /><Value Type='Text'>Global Audit & Assurance</Value></Eq></Where></Query></View>"
}
}
Part 2: Creating an External Data Source
Step 1: Open External Data Connector
- Go to KWIZ App Settings
- Select External Data Connector
- Click New
Step 2: Configure General Settings
- Datasource Type: Web REST API
- Provide Name and Description
Step 3: Configure Connection Tab
URL:
SITEURL/_api/web/lists/getByTitle('LISTNAME')/GetItems
Body:
{
"query": {
"ViewXml": "<View><Query><Where><Eq><FieldRef Name='Business' /><Value Type='Text'>Global Audit & Assurance</Value></Eq></Where></Query></View>"
}
}
Step 4: Configure Display Columns
- Go to Display Columns tab
- Add any additional columns you want to use
You can apply dynamic filtering by using parameters.
You may:
- Edit the same Data Source
- Or copy it and create a new one
Step 1: Add a Parameter
- Go to Parameters tab
- Add a parameter (example:
Title) - Mark it as Required
Step 2: Update the Connection Body
Modify the ViewXml to use the parameter.
Example:
{
"query": {
"ViewXml": "<View><Query><Where><Eq><FieldRef Name='Business' /><Value Type='Text'>[Title]</Value></Eq></Where></Query></View>"
}
}
[Title] will be replaced dynamically when used in the form.
Step 3: Adding Multiple Filters (Advanced)
To add additional filters, rebuild the <Where> clause using proper CAML structure.
Example with two conditions:
<View>
<Query>
<Where>
<And>
<Eq>
<FieldRef Name='Business' />
<Value Type='Text'>[Title]</Value>
</Eq>
<Eq>
<FieldRef Name='Status' />
<Value Type='Text'>Active</Value>
</Eq>
</And>
</Where>
</Query>
</View>
Important:
- Use
<And> or <Or> correctly - Follow proper CAML nesting rules
Step 4: Using the Parameter in a Form
When creating an External Data Source column:
- Provide the filtering parameter
- It can be mapped to a form column
- The value will be passed automatically to the data source
Summary
To use a View in an External Data Source:
- Retrieve the ViewQuery via REST API
- Decode and format the CAML
- Wrap it with
<View><Query> - Add it as
ViewXml in the JSON body - Configure the External Data Connector
To apply dynamic filtering:
- Add parameters
- Replace values in
ViewXml with [ParameterName] - Use proper CAML syntax for multiple conditions