Tagged: Sitecore

5 Essential Sitecore Chrome Extensions

Browser Extensions are handy and easy to use without leaving the tab. Here are the top 5 Sitecore Chrome Extensions I use daily and it saves ton to time! 

Sitecore Author Tool Box

Author: Ugo Quaisse

This extension is a lifesaver and must have! Here is the set of handy tools into Content Editor. Favourites Bar, Desktop notifications, and Dark mode are my favorites.

Download link

 

Sitecore Extensions

Author: Alan Płócieniak

This tool is super helpful, has great features. You can just Ctrl+ Space to search for commands. 

Download here

Also when in the Web database, it shows the red bar on the top to make sure you are not editing in Web DB!

The latest version 3.3 is released, check out the new features here

 

Sitecore Icon Search

Author: Gabriel Streza

This is my favorite extension. You can search and add Sitecore icons without ever leaving the tab.

Download here

Once you choose the icon, it automatically sets the Icon field on the template, and the icon’s relative path is still be copied into the clipboard! 

 

Sitecore Developer Tool

Author: Vlad Shpak

This tool allows navigating to admin pages like cache, serialization, show config (I use this most of the time), etc.  Also, you can switch between databases or set a new database on the options page. 

Download here

Additional tip: If you want the pages to open in a new tab, you can set it in option page and also add any admin pages you want like below

 

Sitecore Analytics Testing Tools

Author: Derek Hunziker

This is a fantastic tool for testing GeoIP and Analytics.

You can clear analytics-related cookies and specify a forwarded IP address for GeoIP lookups.

Download here

 

Pro-Tip:

You can use the same extensions in Microsoft Edge by copy and pasting the same Chrome link in the Edge browser.

Select Allow extensions from other stores in the banner at the top of the page and confirm the popup.

Select the Add to Chrome button and the extension is now added to Edge.

Learn more from here.

 

Hope this helps. Any questions, leave a comment below.

Happy Sitecoring! 

0

Generic method to read values from any type of Form fields

Are you looking for a generic method to read the values from any type of Sitecore Form fields? Here is the solution.

         private static Dictionary<Guid, string> FormFieldsToDictionary(IList<IViewModel> fields)
		{
			Dictionary<Guid, string> fielDictionary = new Dictionary<Guid, string>();
			foreach (var field in fields)
			{
				fielDictionary.Add(Guid.Parse(field.ItemId), field.GetType().GetProperty("Value")?.GetValue(field, null)?.ToString() ?? string.Empty);
			}
			return fielDictionary;
		}
	private static string GetValue(IViewModel field)
		{
			if (field == null)
			{ return default(string); }


			if ((field as StringInputViewModel) != null)
			{
				return (string)(object)(field as StringInputViewModel).Value;
			}

			if (field is ListViewModel)
			{
				var listField = (ListViewModel)field;
				var array = listField?.Value?.ToArray();
				if (array == null)
				{
					return string.Empty;
				}
				return String.Join(",", array);
			}

			if (field is DateViewModel)
			{
				var dateField = (DateViewModel)field;
				return dateField.Value.HasValue ? dateField.Value.Value.ToShortDateString() : string.Empty;
			}

			if (field is NumberViewModel)
			{
				var numberField = (NumberViewModel)field;
				return numberField.Value.HasValue ? numberField.Value.ToString() : string.Empty;
			}

			if (field is TextViewModel)
			{
				var textField = (TextViewModel)field;
				return (string)(object)textField.Text;
			}

			if (field is CheckBoxViewModel)
			{
				var checkbox = (CheckBoxListViewModel)field;
				return (string)(object)checkbox.Value;
			}


			return default(string);
		}

Utilization:

protected override bool Execute(UpdateContactData data, FormSubmitContext formSubmitContext)
		{
			var fieldsDictionary = FormFieldsToDictionary(formSubmitContext.Fields);

           // From here you can create a model from fieldsDictionary, call any API and return call status

       }

Hope this helps someone. Any questions, leave a comment.

Happy Sitecoring!

0

Want to re-index specific item(s) faster?

I recently came across a scenario where I wanted to reindex specific item(s)/folder instead of full content tree. 

Typically I would have reindexed Sitecore_Master DB which takes good amount of time to rebuild all items.

Instead I chose the item(s)/folder, navigated to Developer tab and clicked Re-Index Tree. It was done less than a minute! 

This will rebuild the Item(s) to all the indexes in your solution and I feel this is very quick as compared to traditional re-index.

Note: If you don’t see Developer tab in the menu, you need to enable it by right-clicking on the menu and select the developer option.

Hope this helps someone. Any questions, leave a comment.

Happy Sitecoring.

0

Install Sitecore 9.3 (using SIA) quickly in 20 minutes!

I’m participating in Sitecore Hackathon 2020 for the second time. One of the requirement is to have sitecore 9.3 installed on your machine except for commerce . I want to share my experience how i quickly installed Sitecore 9.3 using SIA(Sitecore Install Assistant) in 20 minutes!

Note: No need install any prerequisites(includes Solr) manually, SIA will take care of it.

Preparation:

  • Download installation package (Graphical setup package XP Single) from here.

Installation:

  • Extract the file zip file downloaded and click on Setup.exe
  • Install the prerequisites if needed. 
  • Install Solr 811 by filling Port, Windows service path prefix and Install path and Install.

Note: Make sure the port number is different from earlier versions of Solr installed. 

  • Fill out site prefix, admin password(going with b, so easy to remember) and license file path.
  • Fill out SQL server instance name, admin username and password.
  • Fill out the Solr URL, System root and Windows service name

Note: Go to Solr URL to make sure it’s running successfully.

  • Select optional module SXA if you need. I’m going for it, time to explore SXA! Would be nice if Horizon is listed here. 
  • Review the summary to make sure the settings are correct.
  • SIA validates to make sure the files look good.
  • Install. This takes around 10 minutes (you can get a coffee!). If it errors out, check out the log.

Yayy!! It’s installed. Is it easy to install with SIA? It’s indeed a great tool!

Check out the release notes for what’s new in Sitecore 9.3 here

Happy Sitecoring!

0

My 2019 Reflections

2019 is going great so far, wanted to share my contributions to the Sitecore community(Awesome!).

Presented Sitecore 9 Forms(Intermediate/Advance) in 7 SUG’s-

• April 18 2019 – SUG Bulgaria
• May 4 2019 – SUG Bangalore
• June 4 2019 – SUG Manchestor, NH
• June 6 2019 – SUG Belarus
• June 12 2019 – SUG Boston
• June 25 2019 – SUG NCR(Delhi -India)
• Aug 29 2019 – SUG Educador

 

The blog posts I have written and one of my blog post received ‘You are life saver, Thank you’ comment.

• Install Sitecore 9.1 quickly in 5 easy steps
• Sitecore 9 Forms: Redirecting to formbuilder on Submit?
• Sitecore 9 Forms: The required anti-forgery cookie __requestVerificationToken is not present
• Sitecore license file expired?
• Sitecore 9.1 Forms: Conditional Logic
• Sitecore 9 Forms: Custom Control – Conditional Section
• Sitecore 9 Forms: Success message
• Sitecore 9 Forms: Custom Submit Action
• Tips and Tricks : GIT Cherry Pick
• Sitecore Certification : Exam and Review
• Sitecore 9 Forms: Save Data
• Sitecore 9 Forms: Custom Regex Validation
• Sitecore 9 Forms: Custom Grouped dropdown
• Sitecore 9 Forms: Uncaught TypeError: Cannot read property ‘unobtrusive’ of undefined
• XConnect: Certificate was not found
• Sitecore 9 Forms: Access landing page fields in FormSubmitContext?
• Sitecore 9 Forms: The date range is invalid. Please select a date range that is within the range of the list.
• Sitecore Forms: Export Data to CSV shows Field Types on column header?
• Sitecore Forms: Redirecting to External URL

Youtube
• How to add Forms Custom Submit Actions – https://www.youtube.com/watch?v=wE_aaFN7GvY

Slack Community
• Active on #wffm-forms

Certification
• Sitecore 9.0 Certified Platform Associate Developer

Participation
• Hackathon

Conferences I attended
• SUGCON India
• SYMPOSIUM
• All SUG Boston meetups.

2020 Plans

Learn and contribute

  • Cortex
  • Sitecore AI Personalization
  • Sitecore 9.3 Forms
  • Sitecore 9.3 Overall

Co-organize (Virtual)

  • Quarterly SUG-Pittsburg meetup

Present

  • SUG Meetups
  • Sitecore SUGCON EU/Symposium 2020
0

Sitecore Forms: Export Data to CSV shows Field Types on column header?

I exported the Forms data using Export the selected data into CSV button and noticed one of the column header was showing field type not field name.

I checked at many places, couldn’t figure out. Later I checked on Content Editor – Forms and found that item name was showing the field type!

I gave the appropriate Field Name in Forms and the CSV file looks good now. 

Forms Field Name sets Item Name and Label sets the Title field in Content Editor.

Don’t forget to publish the Forms!

Happy Sitecoring.

0

Sitecore 9 Forms: Access landing page fields in FormSubmitContext?

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.

Happy Sitecoring!

0

Sitecore 9 Forms: Custom Control – Conditional Section

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 MultiLine Text 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
    public class ConditionalViewModel : FieldViewModel
    {
        public string TargetField { get; set; }
        public string TrueValue { get; set; }

        protected override void InitItemProperties(Item item)
        {
            base.InitItemProperties(item);

            TargetField = StringUtil.GetString(item.Fields["Target Field"]);
            TrueValue = StringUtil.GetString(item.Fields["Show Value"]);
        }

        protected override void UpdateItemFields(Item item)
        {
            base.UpdateItemFields(item);

            item.Fields["Target Field"]?.SetValue(TargetField, true);
            item.Fields["Show Value"]?.SetValue(TrueValue, true);
        }
    }
@using Sitecore.ExperienceForms.Models
@using Sitecore.ExperienceForms.Mvc.Html
@using Sitecore.Mvc
@model  Sitecore.Project.Example.Views.CustomControl.ConditionalViewModel

@{
    var viewModel = Model is IViewModel vModel ? vModel : null;
}

<div @(Sitecore.Context.Request.QueryString["sc_formmode"] != null ? "" : "hidden") class="@Model.CssClass cond-@Model.targetField-@Model.trueValue">
    @Html.RenderFields(viewModel)
</div>

@if (Sitecore.Context.Request.QueryString["sc_formmode"] == null)
    {
        <script type="text/javascript">
            const condArr = [];

            function initConditional() {
                const conditionals = document.querySelectorAll('[class*="cond-"');
                conditionals.forEach((e) => {
                    e.className.split(" ").forEach((c) => {
                        if (c.includes('cond-')) {
                            condArr.push(parseClassName(c));
                        }
                    });
                });
                condArr.forEach((cond) => {
                    const element = document.getElementsByClassName(cond.field_name)[0];
                    element.setAttribute("data-cond", cond.field_name);
                    element.onchange = () => {
                        conditionalChange(element, condArr);
                    }
                });
            }

            function conditionalChange(element, condArr) {
                condArr.forEach((cond) => {
                    if (cond.field_name === element.getAttribute("data-cond")) {
                        if (cond.value === element.value) {
                            document.getElementsByClassName(cond.class)[0].removeAttribute("hidden");
                        } else {
                            document.getElementsByClassName(cond.class)[0].setAttribute("hidden", "true");
                        }
                    }
                })
            }

            function parseClassName(class_name) {
                const arr = class_name.split("-");
                if (arr.length < 3) {
                    console.log(`Malformed className: ${class_name}`);
                } else {
                    const obj = {
                        class: class_name,
                        field_name: arr[1],
                        value: arr[2]
                    }
                    return obj;
                }
            }

            initConditional();
        </script>

Step 4: Update the template fields

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.

0

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