Sitecore Forms Not Loading: "undefined field is_template" Solr Error

Sitecore Forms Not Loading: "undefined field is_template" Solr Error

After Sitecore migration to 10.4.1 Form stopped loading in the Forms app, with no obvious clue from the Sitecore side. As always, the real story was in SOLR.

Issue

Forms wouldn't load. No helpful error in the Sitecore logs pointing directly at the cause just a blank/broken Forms list. Behind the scenes it uses SOLR for listing. First step I did a reindex to see if that fixes the issue that is common, which didn't fix it time to check what Sitecore logs.

Diagnosis

Pulled the actual request Sitecore was firing at SOLR:

https://solr.local:8983/solr/local-dev_master_index/select?q=(((((_content%3a(**)+OR+(_name%3a(**))+OR+(_displayname%3a(**)))+AND+(is_template%3a("1")+AND+_latestversion%3a("1")))+AND+_path%3a("b701850acb8a4943b2bcdddb1238c103"))+AND+_templatename%3a("Form"))+AND+(-__hidden%3a("1")++*%3a*))+AND+_val_%3a__boost&start=0&rows=25&fl=*%2cscore&fq=_indexname%3a(sitecore_master_index)&wt=xml&sort=_displayname+asc&version=2.2

Ran it directly against SOLR and got back a 400:

Checked the log file and confirmed the same thing was happening on every Forms-related request:

"GET /solr/local-dev_master_index/select?q=...is_template%3a(%221%22)... HTTP/1.1" 400 940
"GET /solr/local-dev_master_index/select?q=...is_template%3a(%221%22)... HTTP/1.1" 400 990

Both 400s. Both complaining about the same field: is_template.

To isolate it, I removed is_template out of the query and re-ran it against SOLR:

https://solr.local:8983/solr/local-dev_master_index/select?q=((((_latestversion%3a("1"))+AND+_path%3a("b701850acb8a4943b2bcdddb1238c103"))+AND+_templatename%3a("Form"))+AND+(-__hidden%3a("1")++*%3a*))+AND+_val_%3a__boost&start=0&rows=50&fl=*%2cscore&fq=_indexname%3a(sitecore_master_index)&wt=xml&sort=__smallcreateddate_tdt+desc&version=2.2

It worked as expected and returned 430 results. So the query logic itself was fine. The only broken piece was the is_template field reference.

Solution

Navigate to the index config located in the following path\App_Config\Sitecore\ContentSearch\Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config

Found the spelling issue comparing with the working version, replaced is_template without "_" to istemplate and it started working as expected.

<field fieldName="istemplate" returnType="bool">Sitecore.ContentSearch.ComputedFields.IsTemplate,Sitecore.ContentSearch</field>

Hope this helps save you some time.