I came across a scenario where I needed to access landing page fields(the page where we add Forms) in Custom Submit Action’s FormSubmitContext.
By default, the page item isn’t known at the Submit Action. So started thinking should i create a custom hidden field or use the Forms Extensions module? At the end of the day, i didn’t need either.
Here is the quick way to access the current page using HttpContext’s AbsolutePath.
protected override bool Execute(string data, FormSubmitContext formSubmitContext)
{
var contextItem = GetContextItem.GetItem(HttpContext.Current.Request.UrlReferrer?.AbsolutePath) as ILandingPageContentItem;
// Access fields from ContextItem
}
public class GetContextItem
{
public static IStandardTemplateItem GetItem(string path)
{
Item item = Sitecore.Context.Database.GetItem($"/sitecore/content/<tenant>/Home{path}");
return item?.AsStronglyTyped();
}
}
Hope this helps someone. Any questions, please leave a comment.
I came across a scenario to implement Conditional Section for Sitecore 9.0 to hide/show fields based on user input. This feature was introduced on Sitecore 9.1(Checkout my other blog here). Since the project is in Sitecore 9.0, I decided to create a custom control using speak.
Let’s get started.
Step 1: Create form element in core DB using speak
Switch to Core DB
Go to /sitecore/client/Applications/FormsBuilder/Components/Layouts/PropertyGridForm/PageSettings/Settings
Create a template based of Form Parameters. (I couldn’t find it when i tried from Insert Template, so i duplicated the existed one- MutliLine Text. If you know, how to add Form Parameters template(not using Sitecore Rocks), please leave a comment.)
Add the FormTextBox Parameters template. Since I duplicated MultiLineText field, it came with the Details, Validation, Styling and Advanced. I feel it’s best shortcut to create quick.
Fill out FormLabel, IsLableOnTop and BindingConfiguration fields.
Repeat the fields as many as you need. Here i added one more to compare the value.
NOTE: IsLabelOnTop is unchecked for additional fields
Step 2: Create form template in Master DB
On Master DB, create a custom template under Basic/Lists/Security/Structure folders based on Field Type template(/sitecore/templates/System/Forms/Field Type). I created under Structure Section as it’s Condition Section.
Fill out Property Editor field by choosing the custom control that was created in Core DB. You can see all the fields listed shown in below screen shot.
Fields(View Path, Model Type)will be filled out after creating code behind and razor view files.
Step 3: Create model and view in Visual Studio
Create model and view in project under Helix structure
Now you should see the new form control on the elements panel. Drag and Drop to any form and fill out the Target Field and True Value fields appropriately and put any element(s) inside Conditional Section to show/hide the element(s).
Don’t forget to publish all the templates and forms!
Happy Sitecoring! Leave a comment if you have any questions.
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.
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!
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)
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.
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