Sitecore 9 Forms – SubmitAction simpler example

If you are using Sitecore Form, probably you have the need to extend the SubmitAction… this code snippet is a good example to start creating a custom SubmitAction…

The simpler custom submit action could be used to save data on a log file, and maybe send an email with the data submitted in the form…

Other common scenarios for custom actions are integrating it with the CRM….

This example has been tested with Sitecore 9.02 and should work well also with other versions up to 9.2….

happy forms!

Powershell to publish Helix base solution with VisualStudio 2019 without GULP

As most of Sitecore developers I quickly fall in love with Helix base solution approach but when it comes to developer experience Gulp was not feeling like the best match for build and deployment neither on my local machine…

As you have probably experienced, getting Gulp up and running is pretty simple, but as you start adding projects and complexity to your solution the build time increase exponentially and I have seen solutions where the Gulp build task taking more than 20 minutes, compared to 1-2 minutes of a standard Visualstudio build & publish command….

Therefore my idea to use Powershell even to deploy on my local machine for a full build and publish of my solution locally…

The idea is to hook in the full build and publish of all the projects on the publish of the main website project…

In reality, the code to achieve it, it is pretty simple and you can get it to work pretty easy since you need to worry only about three areas:

  1. Clean up of configs
  2. Build and publish of all the projects
  3. Copy configs that did not come after the full publish

As additional steps, you may consider including the Unicorn or TDS synchronisation to replicate what you do within Gulp but personally, I like to run manually all the items synchronisation to keep closer control and have quicker build and publish time…

Few things to do to get it running:

1.  Install prerequisites

IIS Management Script and Tools must be enabled from ‘turn windows features on or off’

preReqPS.JPG

2. Copy the powershells script and powershell config in the website – configuration folder

You need these two files from my Gist: https://gist.github.com/steliodibello/4cb47563ce43b922b943a000ec072853

remember to replace XXX with your project name

3. Amend the main webiste project to invoke the powershell on the after build step

<Target Name=”PublishAll” AfterTargets=”CopyAllFilesToSingleFolderForPackage”>
<Exec Command=”powershell.exe -NonInteractive –ExecutionPolicy Unrestricted -command &quot;&amp; { &amp;’$(SolutionDir)Configuration\PostPublish.ps1′ -solutionPath ‘$(SolutionDir)’ } &quot;” />
</Target>

 

For further reference and similar blogs who have inspired mine, have a look at:

https://www.onceinawhitemoon.net/2019/04/automatically-deploy-all-sitecore-helix-projects/

and

https://whipeter.wordpress.com/2018/09/07/sitecore-helix-build-and-deploy-powershell-script/

Sitecore 9.2 Dev Environment setup

I am glad to blog about the improvements in the Developer experience installing Sitecore 9.2… in case you have installed already Sitecore 9, you were probably aware of the pain and joy related to it… With Sitecore 9.2 luckily most of the misery is gone and installation is simpler and easier….

Prerequisites

Windows 10 

Not sure which version I have, but certainly, help to have Powershell 5.1 and have an administrator account

SQL server

I went for SQL 2017 Developer edition and a fresh instance dedicated to Sitecore…

As additional configuration steps, remember to enable mixed authentication and do a SQL sysadmin account to install and run your sitecore setup and DB

In addition, I have enabled Contained Database authentication

SOLR

you need to go for version 7.5 I have used this PowerShell script which Peter Prochazka explains in his blog post. I went with OpenJDK  and everything went smooth since no other Java version was present on the laptop

Running the script in an elevated powershell session the magic happen and I had Solr 7.5 up and running.

Sitecore Magic – SIA

this was the best surprise I can find… Graphical setup package for XP Single that you can download from https://dev.sitecore.net/Downloads/Sitecore_Experience_Platform/92/Sitecore_Experience_Platform_92_Initial_Release.aspx

will do the boring job for you… In case you had installed Sitecore 9, you are aware of the long list of prerequisites to install (configure IIS, certificates, packages etc) SIA actually do 99% of it on your behalf, downloading and installing and setting all the prerequisites on your behalf…

The only parameters to provide to SIA will be the  SOLR url: https://solr75:8750/solr and sql instance name and credentials….

Initial

installing prerequisites quietly

PreReq

fill in some settings such as instance name, admin pwd (I always put b…) and license file location

Settings

sql instance details… I recommend not to use sa account but a sql sysadmin account…

sql

and finally

complete

Sitecore Form QuickStart

Hello!

As you probably are aware within Sitecore 9, WFFM was deprecated and Sitecore Form was introduced…

On the base that I do not particularly believe in Marketers building forms, I had fun migrating a few simple forms as part of the migration that I was running, but I do not think that would be an achievable task for dummy content editors/marketers…

First challenge come with the list of forms, on Sitecore 9, I had to rebuild indexes few times to get the valid list of my Sitecore forms (this KB will help you… https://kb.sitecore.net/articles/891856 in my case my user was messing around with languages)

ListForms

Form Elements are the common elements that you will use and 90% will be basic form elements https://doc.sitecore.com/users/91/sitecore-experience-platform/en/the-basic-elements.html

FormElements

Styling a form, in theory, is really simple, see the image:

stylingbutton

but in practice, if you need to change the markup, and in my experience, you will have to, the simpler way is going and editing directly the CSHTML of the view…  You can find these files in Views/FormBuilder/FieldTemplates

But obviously, you are free to extend your own fields, here you can find further information on how to do it: https://doc.sitecore.com/developers/90/sitecore-experience-manager/en/walkthrough–creating-a-custom-form-element.html 

Once you have created your first Sitecore form, it is time to add it to your page…

Your page MUST have an MVC Layout, and then you can use a Form Rendering…

FormRendering