Friday, September 29, 2017

TDS code generation for content items

Code generation of templates works great with glass mapper and TDS in your Sitecore project, however there are times where content items may need to have classes generated. An example would be system pages or settings, which are serialized/deployed and in which item IDs may be required in other areas of code.

Instead of manually declaring these IDs in a static class like the old days, TDS can generate these classes which makes it a bit more dynamic. This makes use of the itempaths.tt transformation file:



And is as simple as editing the properties on the path where you want content serialized - in this case the content item.


Notice that Code Generation Template has been set for this content item. Now when the coder generation is re-run this content item and it's children all have classes available:


Sitecore TDS code generation error Invalid token this

After upgrading my TDS solution to use the new version 3 of the transformation files, on generation an error message would pop up and the following error appeared in the generated file.
An error occured while generating code for item '/sitecore/templates/MyTemplate'.
T4 Template: C:\Projects\MyProject\TDS.Core\Code Generation Templates\glassv3item.tt
Errors:
Compiling transformation: Invalid token 'this' in class, struct, or interface member declaration
Compiling transformation: Method must have a return type
Compiling transformation: Identifier expected
Compiling transformation: 'GeneratedTextTransformation.Write()' must declare a body because it is not marked abstract, extern, or partial
This error is occurring because the glassv3item.tt template as an extra line added at the bottom of the file. Removing this will allow the code to generate without error.

TDS glassv3item new line
Solution via Ryan Tuck.

Upgrades TDS code generation outputs with wrong DLL reference

After updating Glass Mapper, TDS and the tt transformation files, when re-generating code for all items in my TDS project there were references to the old Glass.Mapper.Sitecore DLL instead of the updated Glass.Mapper.Sc DLL.

TDS code generation old DLL

This error was occurring because the TDS project was setup to use the old transform files instead of the V3 ones. Updating t these V3 versions, fixed the error and the correct references were added to the output.

TDS correct transform templates

Sitecore TDS code generation - failed to resolve include text

After upgrading a Sitecore solution's Glass Mapper to the latest version, installing the latest TDS, along with adding in new code generation templates (tt files). The following error was occurring:
Failed to resolve include text for file:C:\Projects\MyProject\TDS.Core\Code Generation Templates\GeneralExtensions.tt
Looking at the item tree where these templates were added, it appeared that the file was referenced as generalextensions.tt - with all lowercase.


By updating the include references in the other files, this error no longer occurred and code would generate the models as expected. An example of the include to update is:
<#@ include file="generalextensions.tt" #>

Monday, September 25, 2017

Sitecore update file upload request filtering module error

When using Sitecore's update installation wizard to install a new version of Sitecore, I was getting the following error message when trying to upload the update file.
The request filtering module is configured to deny a request that exceeds the request content length.

Request filtering module error message

In the upgrade guide it mentioned the the maxAllowedContentLength setting needed to be updated in the web.config file. This is a setting which controls the maximum file size (in bytes) that can be uploaded to the web server.

Web.config maxAllowedContentLength
In my case, this had been updated (and IIS restarted) which should of allowed a maximum size of 4gb, where the update file was only 1gb. The error was still occurring.

It turns out that the instruction stated "\wwwroot\<instance name>\Website\sitecore\admin\web.config" where I had misread and edited "\wwwroot\<instance name>\Website\web.config".

I can't be the only silly person to make this mistake, hopefully this saves someone else some time :)

Sitecore installation wizard access denied

When installing the Sitecore Update Installation Wizard package (via the standard installation wizard on the Sitecore desktop) I was getting the following error:
Access to path 'F:\install\...'
My computer did not have an F drive mapped and the website was configured to use the the standard wwwroot folder on the C drive.

Sitecore installation wizard - access denied error
It turns out that the three folders for the Sitecore website (Data, Databases and Website) did not have the correct permissions assigned to them. By fixing up the security on these folders, the package was able to install as expected. For some reason, the wizard displayed/tried to use a drive which was not mapped.

Tuesday, September 5, 2017

Sitecore WFFM form reports are empty

On a Sitecore instance running version 8.1 and the web forms for marketers module, the form reports were coming up empty.

Sitecore WFFM form reports empty
Looking at the console on the form reports page (as shown above) there were three 500 errors returned for services used to build up data on the page. The error messages for these three services were as follows:
The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Guid' for method 'System.Web.Mvc.ActionResult GetFormFieldsStatistics(System.Guid)' in 'Sitecore.WFFM.Services.Requests.Controllers.FormReportsController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters

The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Guid' for method 'System.Web.Mvc.ActionResult GetFormContactsPage(System.Guid, Sitecore.WFFM.Abstractions.Data.PageCriteria)' in 'Sitecore.WFFM.Services.Requests.Controllers.FormReportsController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters

The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Guid' for method 'System.Web.Mvc.ActionResult GetFormSummary(System.Guid)' in 'Sitecore.WFFM.Services.Requests.Controllers.FormReportsController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters
The first step is to check that the settings items required for the WFFM report queries have been installed correctly. The item at the "/sitecore/system/Settings/Analytics/Report Queries/WFFM" path should have 4 child items.

Sitecore WFFM report queries settings
The next step is to ensure that the WFFM_Analytics.sql file was run on the SQL reporting database at the time of package installation. The following four databases are expected on the reporting/analytics database, if they are not present the SQL file needs to be run:

  1. Fact_FormEvents
  2. Fact_FormStatisticsByContact
  3. Fact_FormSummary
  4. FormFieldValues
Running this script removed the three service errors for me and the form reports started logging/showing data as expected. 

Monday, September 4, 2017

Sitecore TDS The remote certificate is invalid according to the validation procedure error

When trying to do a sync using Hedgehog's Team Development for Sitecore (TDS), it was unable to connect to the local Sitecore instance and the following errors were appearing:
Exception The remote certificate is invalid according to the validation procedure. (AuthenticationException)
Exception The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. (WebException)
This is a similar error to an earlier blog post I wrote about Sitecore rocks getting SSL errors. You need to check what host name the certificate you are using on the Sitecore site is assigned to, in my case it was localhost.

IIS Server Certificates

The the next step was to set this certificate as trusted, which this post covers.

Now by setting the Sitecore Web URL property to https://localhost in the TDS project settings, I was successfully able to sync content into the solution.

TDS Sitecore Web URL