Saturday, September 29, 2018

Step by Step Sitecore 9 Installation



Hi all ,in this post we will see about sitecore 9 update 1 installation using powershell script.

Lets move,

PREREQUISITES

     Windows 10
     Sql Server 2014 or 2016 (for xDB)
     IIS 8.5 > 10 (IIS 8 is not supported by SIF)
     Jave Runtime Environment version 1.8 or higher
     Powershell version 5.1  
     A Sitecore License 


STEP 1 - INSTALL SOLR

Copy the powershell script from the below link
and save it as Install-Solr.ps1 

Create a folder for solr as c:\solr

Update the following variables in the script:

The $JREVersion variable – this should be the same as your Java version
The $JREPath – this should be the path to your Java version

Save the file.

Open powershell with admin permissions and run the following command

Set-ExecutionPolicy RemoteSigned
Then run the script Install-Solr.ps1 



   Once the script completes you should see Solr open in a browser and look like this:






STEP 2 - CREATE KEYSTORE

Run the following in command prompt with administrative privileges

Change the path to the executable based on the path of your JRE installation

“C:\Program Files\Java\jre-9.0.1\bin\keytool.exe” -genkeypair -alias solr-ssl -keyalg RSA -keysize 2048 -keypass secret -storepass secret -validity 9999 -keystore solr-ssl.keystore.jks -ext SAN=DNS:localhost,IP:127.0.0.1 -dname “CN=localhost, OU=Organizational Unit, O=Organization, L=Location, ST=State, C=Country”




After running the above command, a keystore file called solr-ssl.keystore.jks will be created in the current directory.


STEP 3 - GENERATE CERTIFICATE

Run the following in command prompt with administrative privileges.
Change the path of jre before running the command

“C:\Program Files\Java\jre-9.0.1\bin\keytool.exe” -importkeystore -srckeystore solr-ssl.keystore.jks -destkeystore solr-ssl.keystore.p12 -srcstoretype jks -deststoretype pkcs12

This will ask for a password. Enter the password as secret



 This will generate a certificate called solr-ssl.keystore.p12 in the current directory

STEP 4 - INSTALL CERTIFICATE


Double click on the generated solr-ssl.keystore.p12 file and follow the wizard to import the certificate. When you reach the Certificate Store window, make sure to place the certificate in the Trusted Root Certification Authorities.


STEP 5 - MOVE KEYSTORE AND CERTIFICATE TO SOLR

Move the generated certificate and keystore files (solr-ssl.keystore.jks, solr-ssl.keystore.p12) to C:\solr\solr-6.6.2\server\etc\





  
STEP 6 - ENABLE SSL IN SOLR

Edit the file C:\solr\solr-6.6.2\bin\solr.in.cmd
Uncomment properties starting with Solr_SSL_*




STEP 7 - TEST START SOLR

To start solr, run the following in command prompt with administrative privileges

C:\solr\solr-6.6.2\bin\solr.in.cmd -p 8984

Once successfully started up, you should be able to navigate to https://localhost:8984 to make sure that the instance is running.

If no errors are encountered and Solr started successfully, stop Solr by running the command:
C:\solr\solr-6.6.2\bin\solr.in.cmd stop -all


STEP 8 - SET UP SOLR TO RUN AS A WINDOW SERVICE

Run the following in command prompt with administrative privileges.
“C:\solr\nssm-2.24\win64\nssm.exe” install SOLR6

In the insatller window, Set the path to ‘C:\solr\solr-6.6.2\bin\solr.cmd’ ,startup directory to ‘C:\solr\solr-6.6.2\bin’, and  Arguments to ‘start -f -p 8983’.
Enter the service name as SOLR, then click Install Service.
Navigate to https://localhost:8983 to make sure Solr is running.

STEP 9 - PREPARE INSTALL FOLDER
 i)   Create an install folder on your machine, say,‘C:\Sitecore9-Install\resources’.
 ii)  Download the ‘Sitecore 9.0.1 rev. 171219 (WDP XP0 packages).zip’ install file from https://dev.sitecore.net  and unzip the folder.
iii)  Copy ‘Sitecore 9.0.1 rev. 171219 (OnPrem)_single.scwdp.zip’ and ‘Sitecore 9.0.1 rev. 171219 (OnPrem)_xp0xconnect.scwdp.zip’ from the unzipped folder to ‘C:\Sitecore9-Install\resources’
 iv)  Unzip ‘XP0 Configuration files 9.0.1 rev. 171219.zip’ and also copy the contents into: ‘C:\Sitecore9-Install\resources’.Lastly copy your Sitecore licence file into ‘C:\Sitecore9-Install\resources’ also.

STEP 10 - INSTALL SIF
Copy the scirpt from the following link : https://gist.github.com/fluxdigital/5bc46179bf5011fa3c193f05aaa7f176  and save it as Install-Sif.ps1 and run it with admin permissions in powershell.

STEP 11 - INSTALL SITECORE 9 UPDATE 1

Finally you can Install Sitecore. Copy the Powershell Script from the following location:
https://gist.github.com/fluxdigital/50a1978a329c78596e8949643fdbb0b4 and save to your machine as Install-Sitecore9.ps1. It is from the official Sitecore 9 Update 1 install guide.
Edit the following paramaters:
$prefix : Name of your sitecore instance
$PSScriptRoot : set this to your install folder location,                  e.g: ‘C:\Sitecore9-Install\resources’
$SolrUrl : set this to your solr url : https://solr:8983/solr
$SqlServer : Set this to the name of your local SQL Instance.
$SqlAdminUser : SQL DB username eg. ‘sa’
$SqlAdminPassword – Set the password for the user above
Run the script with the correct admin permissions.

All is now ready, Run your instance and enjoy with Sitecore 9 new features .Happy Coding :)




Friday, September 28, 2018

Item Creation Using Sitecore Services Client API -Item Serive (Data from CSV/JSON)

Sitecore.Services.Client provides a service layer on both the server and the client side of Sitecore applications that you use to develop data-driven applications.

It Provides Two Services

ItemService: this service gives you access to regular Sitecore items.
EntityService: this service gives you access to business objects that you define.

In this Post, we will See about Sitecore Item Creation Using Item Service.

What is ItemService ?

 It Provides an Single HTTP End Point and API that you used to interact with sitecore items over HTTP.

Lets Start,

Step 1:  Create a View for uploading a file in the format either JSON or CSV(JSON more Preferable)
If you use Json ,Skip the Step2

Step 2:  Reading CSV File From View.

        var files = $('#fileID').prop('files');
        var file = files[0];
        var reader = new FileReader();
        reader.onload = function (e) {
            var texto = e.target.result;
            CreateCommentItem(csvJSON(texto), "Path");            
        };
        reader.readAsText(file);


The Above code is for Getting File from User end and File Reading.


function csvJSON(csv) {  
    var lines = csv.split('\r');
    for (let i = 0; i < lines.length; i++) {
        lines[i] = lines[i].replace(/\s/, '')//delete all blanks
    }
    var result = [];
    var headers = lines[0].split(",");
    for (var i = 0; i < lines.length; i++) {
        var obj = {};
        var currentline = lines[i].split(",");
        for (var j = 0; j < headers.length; j++) {
             obj[headers[j].toString()] = currentline[j];           
        }
        result.push(obj);
    }
     return result; //JavaScript object
   // return JSON.stringify(result); //JSON
}

The above function will convert your CSV File Into JSON Formatted file.


Step 3:  You need to Initialize the Item Service for Item Creation.


function CreateCommentItem(arr, path) {

//Item Service Initialization
var Service = new ItemService({ url: '/sitecore/api/ssc/item' });

    $.each(arr, function (key, val) {
        if (arr[key].ItemName) {
            arr[key].TemplateID = "Templated ID Goes Here...";
        }
    });
    $.each(arr, function (i, val) {
        if (arr[i].ItemName) {
            Service.create(arr[i]).path(path).execute().then(function (item) {
                window.alert("works");
            })
                .fail(function (err) {
                    window.alert(err);
                });
        }
    });

    event.preventDefault();
    return false;
}


Note: If do not type the correct case for properties when invoking the services, the service returns 500 Error.


Step 4: Don’t forget to add this line to your View

<script src="/sitecore/shell/client/Services/Assets/lib/itemservice.js">
</script>


Step 5: All Now Set, Run Your View Create Items Using ItemService. Happy Coding :)

Sitecore 9 Forms-Creating a Simple Form With Sitecore 9 Form Builder


The Sitecore Forms Let you quickly create and publish forms using form builder that comes with sitecore 9 as a out of box.

Let Start,

   Step 1:  You Can Find a Forms Application in Launchpad.


   
Step 2:  Once You Entered in Forms Application you are able to See Forms Dashboard Like Below.


 Here you can Find
Edit/Rename Form
Export data to CSV Format
Form Details Like Creation time,Created by etc.

Step 3: Click Create,Choose Blank Form, You will also use Forms templates for forms creation.
Now You can See the Form area where you can put your forms elements.



Before start,all you must know about the what are form elements are there,
You can find it in top right corner of your form area.
Basically there are four Types of forms elements are there,
Basic Elements
Text
Number
Single-line text
Multiple-line text
Email
Telephone
Checkbox
Date


Lists
Dropdown list
List box
Checkbox list
Radio button list


Structure
Section
Page
Submit button
Security
Password
Password Confirmation.


Am not going to explain each of this, I believe as all of you know about this.

Step 4: Drag Page Element to your form area. Inside this, You Can add any number of forms that you want.



Add Some elements that Make up your form, Here i am going to create simple request Form.

Here you go, the form is ready,



Also I want to tell some thing, you can also use your custom css to make your form more user friendly ,and interactive. If you need to set button color to red, click on the button, on the left corner, you will find the Styling section here you can add custom classes to make your button more stylish.


Step 5: Sounds good ,The form is Ready, The next thing is you need to make your form rendered on web page.

Create a Layout named as Welcome.cshtml. Inside this,create a placeholder named Sample,
The View Looks Like this,




Step 6: After that, Go to content editor,

Create layout named Sample, and put your welcome.cshtml path to the path field of the layout.
Create a Item named Sample.
And go to Presentation details .
Inorder to your form is visible in the web page you need to use Mvc Form Rendering in the placeholder.Click Edit Put your form in the data source.
You can find in the path Layout/Renderings/System/Forms/Mvc Form




Step 7: Also I need to share one more thing ,Submit Actions
Use the submit button for navigation (previous and next buttons), to submit the form, and/or to trigger submit actions. The submit button is located in the Structure section of the Form elements pane. Here some of these
Save data
Redirect to Page
Trigger Goal/Campaign
Send Email Campaign Message


In this example I have attached Save data Submit action for Saving Request Information's.

Step 8: All is now set ,Run Your Item Enjoy with Sitecore Forms..Happy Coding :)


Check the users Logged into the sitecore backend

Hi, Today I'm going to discuss about " how to check the concurrent users logged into the sitecore backend ? ". For this ...