Category: Sitecore

Sitecore license file expired?

I have Sitecore 9.1 instance and today my sitecore license file expired. I had to replace the license.xml in multiple places to make sure my site, xConnect and Identity Server sites work.

  • Sitecore site:
    • The /App_Data folder
  • xConnect site:
    • /App_Data
    • /App_Data/jobs/continuous/AutomationEngine/App_Data
    • /App_Data/jobs/continuous/IndexWorker/App_Data
    • /App_Data/jobs/continuous/ProcessingEngine/App_Data (new to Sitecore 9.1)

Hope this helps if you have license expiration message.

Happy Sitecoring!

0

Sitecore 9 Forms: The required anti-forgery cookie __requestVerificationToken is not present

Have you submitted a form and it returned with this error ‘The required anti-forgery cookie “__requestVerificationToken” is not present’? If so, here is the resolution.

  • This could be because of caching. Can you check if your rendering component or container/page level caching check box is checked? if so, unchecking the caching will fix the issue.
  • Also here is quick check you can do to see whether your form is cached – Inspect the form and check the _requestverificationtoken value like below and refresh the page – do you see same value now? if so, your form is in cache!
 <input name="__RequestVerificationToken" type="hidden" value="O0P3KYBqgEZXlksWnY3fhu0PptEB0a47rRGMgHNnF6lIL2S8tcts9z9NxdxIum7ANKMv95FZB275AeLTw6WxcOl4jCQ1">  

2

Install Sitecore 9.1 quickly in 5 easy steps

Image result for install software

I’m participating in Sitecore Hackathon for the first time this year. One of the requirement is to have sitecore 9.1(Initial version) installed on your machine. So I want to share my experience how i quickly installed Sitecore 9.1 using SIF on developer machine in 5 easy steps. This post includes the prerequisites, preparation and installation.

Prerequisites:

  • OS: Windows 10, Windows Server 2016
  • DB:
    • Microsoft SQL Server 2017 or 2016 SP2 – Supports the XM database and is the required for the xDB
    • Microsoft SQL Server 2014 Sp2 – Only supports XM databases and does not support the xDB
    • MongoDB Server 3.6.6 – This is required if you are going to use MongoDB for the Collection database or as a Session State Provider
  • IIS 10
  • . NET
    • Sitecore XP 9.1.0 requires .NET Framework 4.7.1
    • Sitecore Identity server requires .NET Core Runtime 2.1.3
    • You must apply any available updates to the .NET Framework on every Sitecore installation
  • Search Indexing
    • Solr 7.2.1 – Default search provider
    • Azure Search – supported and recommended for Azure Cloud PaaS deployments only
    • Lucene – Only supports content search and does not support xConnect.
  • Powershell 5.1 – for Installing SIF

Preparation:

  • Download installation package(XP Single) from here
  • Extract the zip file you just downloaded
  • Again extract this file – XP0 Configuration files 9.1.0 rev. 001564.zip
  • Copy your license.xml file (If you have enrolled for Hackathon, you should have received the file in email)

Now let’s begin the installation!

Step 1: Solr 7.2.1 Install

Check out Jeremy Davis’s low effort Solr installs. It’s pretty cool! https://jermdavis.wordpress.com/2017/10/30/low-effort-solr-installs/

If you want to take traditional approach(Install as service using NSSM tool), here are the steps

  • Download Solr from here
  • Install as service using NSSM tool

  • It opens the NSSM Service Installer like below. Fill out the fields.
  • Note: If you already another version of solr running, make sure to give different port name.
Solr 5 running as a service on Microsoft Windows

Step 2: Install SIF

Run the following scripts in Powershell as administrator.

Register-PSRepository -Name SitecoreGallery -SourceLocation https://sitecore.myget.org/F/sc-powershell/api/v2;
Install-Module SitecoreInstallFramework;
Install-Module SitecoreFundamentals;
Update-Module SitecoreInstallFramework;
Update-Module SitecoreFundamentals;
Import-Module SitecoreFundamentals -Force;
Import-Module SitecoreInstallFramework -Force;

Step 3: Update config files

Update the following files in the folder with the exact information – solr path, solr service name, configsets path, instance name for sitecore, SQL instance name and login credentials.

  • XP0-SingleDeveloper.ps1
  • XP0-SingleDeveloper.json
  • xconnect-solr.json
  • sitecore-solr.json

Step 4: Install prerequisites

Install-SitecoreConfiguration -Path .\Prerequisites.json

Step 5: Install Sitecore 9.1

  • Execute the script ./XP0-SingleDeveloper.ps1 (takes good amount of time to execute)
  • Fingers crossed!

Note: There is no ‘b’ admin password. You can get the password at the end of the script execution. Nice work Sitecore!

Notice that it installed the third site in IIS – Identity Server (New to 9.1)

Also noticed the http://[sitename]/sitecore/login now redictes to identiyserver in the URL.

Have fun exploring Sitecore 9.1!

Any questions, please leave a comment.

0

Sitecore 9 Forms: Redirecting to formbuilder on Submit?

Problem:

Have you submitted a form and it redirected to form builder url and displayed without styles? If so, here is the solution

Resolution:

  • Make sure to add these scripts to MVC OuterLayout.cshtml and reference it in MVCLayout.cshtml. More details, refer the documentation (Steps 3 and 4)
@using Sitecore.ExperienceForms.Mvc.Html  

@Html.RenderFormStyles()
@Html.RenderFormScripts() 

Any questions, please leave a comment. Happy sitecoring!

0

Sitecore Certification : Exam and Review

I recently took the Sitecore 9.0 Certified Platform Associate Developer exam online and passed with an overall score of 88%.

Here are the steps I have taken to become certified:

  • Took the Developer’s Fundamental Collection online. You can also do it through Instructor-Led or Virtual Classroom options – https://learning.sitecore.com/#homepage-learning-solutions
  • Went through all the modules and lab exercises. When I completed the fifth module, I received an access key in the email to book the exam.
  • You can book the exam in-person in the center or online. I chose online and booked the exam via https://www.webassessor.com/sitecore/index.html
  • This is a proctor guided exam, no book allowed. Also, the exam software Senitel says you should have an external web camera. It worked with the in-built camera on my work computer. So don’t worry about the external camera.
  • The exam has 50 questions and 90 minutes to complete. You can review the answers as many times as you want. I completed the exam in 30 minutes and review the answers in the next 30 minutes and I still have 30 more minutes left!
  • Overall I got a 88% score. Here is my Topic level scoring:

Architecture: 100%
Creating and Editing Items: 100%
Development Environment: 75%
Docs and Support: 100%
Installation: 100%
Publishing: 100%
xManagement: 100%
Field Types: 83%
Media: 100%
Templates: 85%
Versioning: 100%
Presentation: 77%
API: 100%
Modules and Packages: 100%
Performance: 100%
Search: 80%

  • Once you complete you exam, you will receive an email from test center with score and certification pdf file. Good luck!

Note:

  • Sitecore Professional Developer – This examination is for Version 8.2
  • Sitecore Certified Platform Associate Developer – This is for Version 9.0

0

Sitecore 9 Forms: Custom Submit Action

One of most common scenario I came across in Sitecore 9 Form is to create your custom submit action. You can achieve this in three simple steps.

Step 1: Create submit action button in Sitecore

Create the custom action button under /sitecore/system/Settings/Forms/Submit Actions.

Step 2: Create code behind class

Create a class that inherits SubmitActionBase class and override the Execute method.

public class CustomSubmitAction : SubmitActionBase<string>
{
public CustomSubmitAction(ISubmitActionData submitActionData) : base(submitActionData)
{
}

public override void ExecuteAction(FormSubmitContext formSubmitContext, string parameters)
{
Assert.ArgumentNotNull((object)formSubmitContext, nameof(formSubmitContext));

if (this.TryParse(parameters, out string target))
{
try
{
if (this.Execute(target, formSubmitContext))
return;
}
catch (ArgumentNullException ex)
{
}
}
formSubmitContext.Errors.Add(new FormActionError()
{
ErrorMessage = this.SubmitActionData.ErrorMessage
});
}

protected override bool Execute(string data, FormSubmitContext formSubmitContext)
{
Assert.ArgumentNotNull(data, nameof(data));
Assert.ArgumentNotNull(formSubmitContext, nameof(formSubmitContext));

//Prepare model here
var model = new EmailModel()
{
Email = GetValue(formSubmitContext.Fields.FirstOrDefault(f => f.Name.Equals("EmailAddress")))
};

// Call any API service call

return true;
}

private static string GetValue(object field)
{
return field?.GetType().GetProperty("Value")?.GetValue(field, null)?.ToString() ?? string.Empty;
}

protected override bool TryParse(string value, out string target)
{
target = string.Empty;
return true;
}

Step 3: Set the custom submit action fields

Update the ModelType and Error Message on the button shown below.

Bind the custom submit action to Submit button like below.

Publish the button. The submit button on form should now trigger the custom save action! Any questions, let me know.

Happy sitecoring.

2

Sitecore 9 Forms: Success message


Sitecore 9 form feature is awesome and simple to work with. It is more like Visual Studio Toolbox and you can drag and drop the fields.

I had a requirement from Client asking for Ajax form and wanted to show Confirmation/Success message after the form is submitted. Out of the box, this is achievable with the Form.

Here is a small guide on how to create a form with confirmation message:

1. Select Forms from Dashboard.

2. Click Create button.
3. Select blank form.

4. Drag a page for main content.
5. Drag a another page for confirmation message.
6. Design the fields according to needs. Here I’m doing Email Signup form. You can add field validation and css-class as needed.

Please make sure you have these scripts in Layout.cshtml.

@Html.RenderFormStyles()
@Html.RenderFormScripts()

7. On the submit button, set the Navigation step to Next instead of submit. This does the trick to show the confirmation page.

7. Save the form.
8. Now you can see the form in Content Editor.

Don’t forget to publish the form and place it on a web page under MVC layout. Here is Sitecore documentation on Adding a form to webpage.

Happy Sitecoring.

0