Sunday, January 6, 2019

Azure chat-bot struck at first time loading after creating new bot service

Hi all,

I was working on Azure chat bot, after creating a sample chat bot using Azure bot service and i have observed that it struck at loading the window in Test in Web Chat.

Here the screen shot.


Then go to the console and observed the below error message and i understood that some modules are not loaded due to npm is not installed for this web application.

Here the screen shot.

Now i have opened the console and run the below command to install npm.

Here the screen shot.



After successfully installation of npm build the solution and run it.

After that go to test chat bot page and reload it.

Now it is opened as expected and tested my BOT.



Saturday, December 23, 2017

Set up SharePoint Framework development environment

SharePoint Framework
Microsoft SharePoint Framework is a new development model. It is built with a set of tools to build on top of Microsoft SharePoint. It provides full support for client-side SharePoint development, easy integration with SharePoint data, and support for open source tooling. It works for both SharePoint on-premises and SharePoint Online.

Setup Development Environment
Now we will go through the process of setting up the development environment for SharePoint Framework in windows operating system. The process is described below.

Install Node JS
Install NodeJS Long Term Support (LTS) version from here

After installation, Open Powershell and type the below command to verify the version.

npm -v

Make sure you are running V3 version of npm.

Also run the below command to install windows build tools for SharePoint framework projects

npm install -g --production windows-build-tools
– install globally this is used to build SharePoint framework projects.

Install Yeoman

Yeoman is the modern scaffolding tool. It helps you kick-start new projects, and prescribes best practices and tools to help you stay productive.
Go to PowerShell window and type as below,

npm install -g yo

It is a good idea to check that everything is installed as expected by running commonly used Yeoman commands like below.

yo –version (2 hyphens)

Install Yeoman SharePoint Generator
The Yeoman SharePoint web part generator helps you quickly create a SharePoint client-side solution project with the right toolchain and project structure.
Enter the following command to install the Yeoman SharePoint generator:

npm install -g @microsoft/generator-sharepoint

Install Gulp
Gulp is a JavaScript task runner that lets you automate tasks such as Bundling and minifying libraries and stylesheets, refreshing your browser when you save a file, quickly running unit tests, Copying modified files to an output directory etc.
Install the gulp command,

npm install –global gulp-cli

Code editor (Visual studio code):
The development environment is already ready. Now use any code editor or IDE that supports client-side development to build web part. My personal preference is Visual Studio Code. Get the setup file of Visual Studio Code from here.

Now we are good to build our first SharePoint Framework project.

Note: If you install lates node.js then check node version by using the below command.

Node -V

and its out is something like this v8.9.x then you need to set a windows environment variable because this is caused by the experimental http/2 feature that is a part of Node v8. Due to that you won't be able to open the workbench in the browser.

After setting windows variable you need to restart your machine.

Or else you need to downgrade your node version to v6.x.


Wednesday, December 14, 2016

How to inject javascript in SharePoint Online with powershell

Hi All,

As we know that SharePoint Online recommended not to update master pages.
If we want to add/update master page we have to use inject JavaScript to any Site or Site Collection via a User Custom Action's ScriptLink property.

we can add user custom actions in different ways.

I. Using PowerShell:

i. Upload the files, like JQuery, custom javascript and css files.
ii. Now open powershell and connect to SharePoint online as below.

$urlAdmin = https://YOUR.TENANT-admin.sharepoint.com
$user = "administrator@YOUR.TENANT.onmicrosoft.com"
$password = "YOUR.TENANT.PASSWORD"
$urlSite = https://YOUR.TENANT.sharepoint.com/sites/TestSiteCollection

$passwordSecureString = ConvertTo-SecureString -string $password -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $user, $passwordSecureString

Connect-SPOService -Url $urlAdmin -Credential $credential

$spoCredentials = New-Object -TypeName Microsoft.SharePoint.Client.SharePointOnlineCredentials -argumentlist $user, $passwordSecureString

iii. Now add custom actions as below

#Injecting JQuery file
$spoCtx = New-Object Microsoft.SharePoint.Client.ClientContext($urlSite)
$spoCtx.Credentials = $spoCredentials
$spoCtx.RequestTimeout = "500000"
$newAction = $spoCtx.Site.UserCustomActions.Add();
$newAction.Location = "ScriptLink";
$newAction.scriptSrc = "~SiteCollection/SiteAssets/scripts/jquery-2.1.3.min.js";
$newAction.Sequence = 1001;
$newAction.Update();
$spoCtx.ExecuteQuery();

#Injecting custom javascript file
$newAction = $spoCtx.Site.UserCustomActions.Add();
$newAction.Location = "ScriptLink";
$newAction.scriptSrc = "~SiteCollection/SiteAssets/scripts/CustomJS.js";
$newAction.Sequence = 1002;
$newAction.Update();
$spoCtx.ExecuteQuery();

Thats it now you can add other javascript/css files from CustomJS.js files.

Its so simple right!!!

Here the complete code.




Friday, February 26, 2016

Error Type: The type or namespace name 'LayoutsPageBase' could not be found

Hi Guys,

Today i want to share about one common error in SharePoint is "The type or namespace name 'LayoutsPageBase' could not be found".

This error occurs while we working on creating application page in visual studio.


The reason for this error is when we try to create application page in sandbox solution it will throw this error. As we know that we can create application as form solution only but not in sandbox solution.


Hence, now change the Sandbox solution property value to "False" and try to compile and deploy it.

Friday, February 5, 2016

News ticker in SharePoint with AngularJS/RestAPI - Part 2

Hi all,

In my previous blog, have shown how to use news ticker in a page/master page.

Now i want to show one more type of active news ticker

Here the steps.

1. Create custom list named as "News" with two columns i.e. PageURL, HeadLines, IsActive.

2. Add few items to the list.




3. Now we want to show only active news headlines so we are changing RestAPI call as below,

var restUrl = _spPageContextInfo.webAbsoluteUrl+"/_api/web/lists/getbytitle('" + listTitle + "')/items?$filter=isActive eq 1";

As i told in the previous we can use the below snippet in a page or in master page.

Here the code snippet.



Here the final output..




Here the complete source code.


News ticker with AngularJS/RestAPI in SharePoint

Hi all,

In this post, i want to show you how to add news ticker in SharePoint with AngularJS/RESTApi.

Here the steps:

1. Create custom list named as "News" with two columns i.e. PageURL, NewsBody.

2. Add few items to the list.

















3. Now upload required javascript/css files named as
    a. modern-ticker.css
    b. theme.css
    c. jquery-1.11.0.min.js
    d. angular.min.js

4. Here am adding new page to show the news ticker and you may can add this snippet in your master page.

Here the complete code snippet for new ticker,





Here the final Output:





Here the complete source code.

Friday, January 22, 2016

How to upgrade SharePoint from one version to another version without any downtime

Hi All,


Today I want to share about how to upgrade SharePoint farm from one version to another version without downtime. This is the best approach when we are working on business application where we can not take down time or we can say where will have impact on business if we take down time like banking applications.


Here we need to set up Disaster Recovery farm has been set up with SQL Server AlwaysOn.


Now follow the below steps to upgrade SharePoint farm.


Step 1: Leave users going to primary site and meanwhile patch disaster-recovery/secondary site.
    1. Ddetach the content database from the DR farm 1st, as PSConfig will fail to finish the upgrade while these databases are still connected to the farm & in read-only mode (as the DR site will still be the secondary replica in SQL Server).
    2. syntax: Dismount-SPContentDatabase <ContentDB GUID>
    3. PSConfig will update all databases except the content databases.
    4. Re-attach the content databases, and maybe even run an incremental crawl if you want your indexes to include updates since the content DBs went offline.
    5. Syntax: Mount-SPContentDatabase <databasename> -DatabaseServer <db_server> -WebApplication <webapplication_URL>
       
    6. Verify SharePoint is happily working again on the DR site – check logs, site-access etc


Step 2: Switch users to the upgraded DR site + failover SQL Server to use the secondary node as the new primary. SharePoint on the DR site will use the content-databases in compatibility mode but with read/write access.
There will be a service interruption while this simultaneous databases + user switchover happens. Might want to make the switch at night, for example.

Step 3: Patch primary farm, now that users are on the DR site.
Once the normal farm is verified as healthy again, failover users there again if you so wish.
Both farms are now upgraded with content-databases in compatibility mode.

Step 4: On the farm with read/write access to the content-databases, finish the upgrade with Upgrade-SPContentDatabase. This may cause some read-only access while the upgrade is happening but it’ll be much less read-only time than the safer method below.
This is the preferred way: read/write functionality still works for users almost without interruption. This full functionality is available much more than was previously possible as AlwaysOn lets us switch primary servers back & forth trivially.


Shortly: upgrade DR farm 1st (with content DBs disconnected) while users still use the primary farm. Then reconnect content DBs, switch users + content DBs at the same time to DR farm once the DR farm is upgraded. Once everyone’s on the DR farm, upgrade primary farm. Finally upgrade content-databases in PowerShell.


Reference