SlideShare a Scribd company logo
1 of 30
BUILD YOUR
FIRST SHAREPOINT
FRAMEWORK WEBPART
https://github.com/eoverfield/SPFx-Demos
ERIC OVERFIELD | PixelMill
Microsoft MVP & RD
SharePoint Advocate & Enthusiast
@ericoverfield
ERIC OVERFIELD
President & Co-Founder of PixelMill
Microsoft MVP, Office Servers & Services
Microsoft Regional Director
Published SharePoint Author
SharePoint Community Organizer & Contributor @ericoverfield
ericoverfield.com
PixelMill is a modern SharePoint Design Agency based in Northern California. On the forefront of
web design trends since 1998, PixelMill provides innovative collaboration portals to enhance the
user adoption of SharePoint intranets, extranets, and public facing sites.
PIXELMILL
@pixelmillteam
pixelmill.com
1. SharePoint Framework (SPFx) Overview
2. SPFx Toolchain – the Build Environment
3. SPFx Webpart Components
4. Webpart Properties, Packaging & More
OVERVIEW
@ericoverfieldericoverfield.com
HISTORY OF SHAREPOINT DEVELOPMENT MODELS
2013
APP/ADD-IN MODEL
2010
SANDBOX
2003
FULL TRUST
2016
CLOUD FRIENDLY SPFx
A page and web part model with full support for client-side SharePoint development
• Open source tooling / toolchain
• nodeJS, npm, Yeoman, gulp, TypeScript, webpack and more
• Easy integration with SharePoint data
• Rest API wrapper classes
• Available in the cloud and On-prem*
• Generally available on SharePoint Online
• On-prem availability scheduled for 2017
WHAT IS THE SHAREPOINT FRAMEWORK?
SPFx – Welcome to integrated client-side rendering
• Client-side rendering
• No server side/compiled code / C#
• IDE / Development platform agnostic
• New / modern tool chain
• nodeJS / Yeoman / Gulp / Reach / etc
• Not dependent on JavaScript Injection
• No iFrame
• Direct integration with the page model
HOW THE FRAMEWORK IS DIFFERENT
@ericoverfieldericoverfield.com
TOOLSET COMPARISION
Project Templates
SERVER SIDE DEVELOPMENT VS SPFx TOOL CHAIN
THE SPFx TOOLCHAIN
A DEVELOPMENT ENVIRONMENT
• Office 365 / SharePoint Online tenant
• App catalog for deployment
• http://dev.office.com/sharepoint/docs/spfx/set-up-your-developer-tenant#create-app-catalog-site
• Development workstation
• PC / iOS / Linux – few limitations
• Toolchain is open source – do not need a dedicated dev env
• Much more simple than classic SharePoint Development
PREREQUISITES
• https://dev.office.com/sharepoint/docs/spfx/sharepoint-framework-overview
• Use any most OS / workstation
• Install nodeJS (current Long Term Support (LTS) version)
• Yeoman and Gulp
• C:> npm i –g yo gulp
• SPFx Yeoman generator
• C:> npm i –g @microsoft/generator-sharepoint
• C:> npm update –g @microsoft/generator-sharepoint
• Use code editor
• VS Code / Sublime Text / NotePad++, etc
A SHAREPOINT FRAMEWORK DEVELOPMENT ENVIRONMENT
Demo
SPFx DEVELOPMENT ENVIRONMENT
• C:> md helloworld-webpart
• C:> cd helloworld-webpart
• C:> yo @microsoft/sharepoint
• Grab a cup of coffee – first time in a project, this will take a while
• You can execute yo command again to add more webparts to project
• Each addition of a webpart to a project will take much less time to scaffold
• C:> gulp serve
• Check out your first webpart!
• It “should” be that simple
• May also load in SPO workbench:
https://”tenant”.sharepoint.com/sites/”site”/_layouts/15/workbench.aspx
CREATE YOUR FIRST SPFx WEBPART
Demo
YOUR FIRST
SPFx WEBPART
WELCOME TO A NEW
DEVELOPMENT PARADIGM
WEBPART SOURCE OVERVIEW
Get to know your Webpart folder structure
• src: primary webpart TypeScript source code
• config: json configuration files for build process
• typings: TypeScript typings for JS libs – legacy
• lib: Build files (TS compiled JS) ready for bundle
• dist: Final web ready code for distribution
• sharepoint: .spapp file for App Catalog
• node_modules: NodeJS modules (JS) for toolchain
@ericoverfieldericoverfield.com
WEBPART PROPERTIES
Webparts normally need custom properties
• Webparts normally need custom properties
• Define: /src/webparts/”webpart”/”webpart”Props.ts
• Add in JSON
• Default values: /src/webparts/”webpart”/”webpart”.manifest.json
• Add in JSON: preconfiguredEntries.properties
• Display: /src/webparts/”webpart”/”webpart”.ts
• Method: protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {}
• Override onchange: /src/webparts/”webpart”/”webpart”.ts
• Method: public onPropertyPaneFieldChanged (propertyPath: string, oldValue: any ,
newValue: any) {}
@ericoverfieldericoverfield.com
ACCESS DYNAMIC DATA IN PROPERTY PANE
• Method getPropertyPaneConfiguration returns a static IPropertyPaneConfiguration
• Method does not allow for Promises / dynamic data
• Solution: Load dynamic data within onPropertyPaneConfigurationStart() or onInit() then
trigger pane refresh
• this.context.propertyPane.refresh(); //cause pane to refresh with new data
@ericoverfieldericoverfield.com
CONNECT TO SHAREPOINT / DYNAMIC DATA
• SPFx provides tools to quickly interact with external API data
• TypeScript Http classes within @microsoft/sp-http
• this.context always includes spHttpClient!
• HttpClient
• Basic set of features for REST operations with any external resource
• SPHttpClient
• REST calls against SharePoint
• Handles context, security, etc. Could use HttpClient if desired
import { SPHttpClient } from '@microsoft/sp-http';
this.context.spHttpClient.get(this.context.pageContext.web.absoluteUrl +
`/_api/Lists/?$select=Id,Title&$filter=Hidden ne true`, SPHttpClient.configurations.v1)
.then((response: SPHttpClientResponse) => {
return response.json();
});
}
Demo
SPFx WEBPART: OVERVIEW,
PROPERTIES AND SHAREPOINT DATA
PACKAGE YOUR WEBPART FOR DEPLOYMENT
• Set deployment configuration
• config/package-solution.json – general settings and package name
• write-manifests.json – CDN / bundle location – for dev, can serve locally: gulp serve --nobrowser
• C:> gulp clean (cleans sharepoint and temp folders)
• C:> gulp build (Rebuilds the solution)
• C:> gulp bundle (Creates the solution bundles)
• C:> gulp package-solution (Creates /sharepoint/”webpart”.spapp)
• C:> gulp –ship (minifies bundle and reads in CDN info from config/write-manifests.json)
• C:> gulp package-solution --ship (Recreates /sharepoint/”webpart”.spapp with CDN info)
PACKAGE YOUR WEBPART FOR DEPLOYMENT
• After solution created, can then add to SharePoint
• Add .spapp to app catalog
• Add app to SharePoint site
• Add webpart in site to content page
• Webpart is still pointing to local host for JS
• Configure CDN for full webpart deployment
• https://dev.office.com/sharepoint/docs/spfx/web-parts/get-started/deploy-web-part-to-cdn
• Or manually deploy solution bundle and config write-manifests.json
Demo
DEPLOY SPFx WEBPART
TO SHAREPOINT
CONNECT TO EXTERNAL LIBRARIES / FRAMEWORKS / RESOURCES
• External libraries and component require Typings
• i.e. for jQuery:
• C:> npm install --save jquery
• C:> npm install --save @types/jquery
• Add to bundle – config/config.json
"externals": {
"jquery":"node_modules/jquery/dist/jquery.min.js“
},
• Within webpart
• import * as myjQuery from 'jquery';
• Access: let $workspace: jQuery = myjQuery(‘#spPageChromeAppDiv');
SPFx COMMAND REFERENCE
• yo @microsoft/sharepoint // create a new base project
• gulp serve // compile and start up local workbench
• gulp serve --nobrowser // same as serve, but with no browser loaded
• gulp package-solution // compile / create spapp file for redeployment in "Sharepoint" folder
• gulp package-solution --ship // create minified component assets
• gulp bundle // generate assets (js, css, etc) for deployment to CDN
• gulp deploy-azure-storage // deploy assets to Azure storage as defined in config/deploy-azure-
storage.json
1. Learn TypeScript!
2. Use SPHttpClient to connect to SharePoint
• HttpClient for other API’s
3. Use frameworks and libraries that already has typings
4. Office UI Fabric available for consistent styling
5. Further Documentation Likely Exists
• https://dev.office.com/sharepoint/docs/spfx/sharepoint-framework-overview
RECOMMENDATIONS
REVIEW
1. SharePoint Framework (SPFx) Overview
2. SPFx Toolchain – the Build Environment
3. SPFx Webpart Components
4. Webpart Properties, Packaging & More
RESOURCES
RESOURCES
• SharePoint Framework documentation
https://dev.office.com/sharepoint/docs/spfx/sharepoint-framework-overview
• SharePoint Framework API
https://dev.office.com/sharepoint/reference/spfx/sharepoint-framework-reference-overview
• Build your first webpart
https://dev.office.com/sharepoint/docs/spfx/web-parts/get-started/build-a-hello-world-web-part
• Add properties to a SPFx Webpart
https://dev.office.com/sharepoint/docs/spfx/web-parts/basics/integrate-with-property-pane
• Connect a SPFx webpart to SharePoint Data
https://dev.office.com/sharepoint/docs/spfx/web-parts/get-started/connect-to-sharepoint
• Webpart with React and Office UI Fabric
https://dev.office.com/sharepoint/docs/spfx/web-parts/get-started/use-fabric-react-components
• Get an introduction to the SharePoint Framework
https://channel9.msdn.com/Events/Ignite/2016/BRK2114-TS
• Demo Source Code
https://github.com/eoverfield/SPFx-Demos
THANK YOU
BUILD YOUR
FIRST SHAREPOINT
FRAMEWORK WEBPART

More Related Content

What's hot

SPS Paris: Building great client-side web parts with spfx, pnp-js-core, React...
SPS Paris: Building great client-side web parts with spfx, pnp-js-core, React...SPS Paris: Building great client-side web parts with spfx, pnp-js-core, React...
SPS Paris: Building great client-side web parts with spfx, pnp-js-core, React...
Bill Ayers
 
SPUnite17 Migrating your Customizations from On-prem to SharePoint Online
SPUnite17 Migrating your Customizations from On-prem to SharePoint OnlineSPUnite17 Migrating your Customizations from On-prem to SharePoint Online
SPUnite17 Migrating your Customizations from On-prem to SharePoint Online
NCCOMMS
 

What's hot (20)

Broaden your dev skillset with SharePoint branding options
Broaden your dev skillset with SharePoint branding optionsBroaden your dev skillset with SharePoint branding options
Broaden your dev skillset with SharePoint branding options
 
Introduction to SharePoint Framework (SPFx)
Introduction to SharePoint Framework (SPFx)Introduction to SharePoint Framework (SPFx)
Introduction to SharePoint Framework (SPFx)
 
SPS Paris: Building great client-side web parts with spfx, pnp-js-core, React...
SPS Paris: Building great client-side web parts with spfx, pnp-js-core, React...SPS Paris: Building great client-side web parts with spfx, pnp-js-core, React...
SPS Paris: Building great client-side web parts with spfx, pnp-js-core, React...
 
An Introduction to the Office 365 Patterns and Practices Project
An Introduction to the Office 365 Patterns and Practices ProjectAn Introduction to the Office 365 Patterns and Practices Project
An Introduction to the Office 365 Patterns and Practices Project
 
SPUnite17 SPFx Extensions
SPUnite17 SPFx ExtensionsSPUnite17 SPFx Extensions
SPUnite17 SPFx Extensions
 
All about SPFx
All about SPFxAll about SPFx
All about SPFx
 
Do's and don'ts for Office 365 development
Do's and don'ts for Office 365 developmentDo's and don'ts for Office 365 development
Do's and don'ts for Office 365 development
 
What's in SharePoint land 2016 for the end user
What's in SharePoint land 2016 for the end userWhat's in SharePoint land 2016 for the end user
What's in SharePoint land 2016 for the end user
 
SPUnite17 Migrating your Customizations from On-prem to SharePoint Online
SPUnite17 Migrating your Customizations from On-prem to SharePoint OnlineSPUnite17 Migrating your Customizations from On-prem to SharePoint Online
SPUnite17 Migrating your Customizations from On-prem to SharePoint Online
 
ecs19 - Bill Ayers - RE-USE YOUR SHAREPOINT FRAMEWORK SKILLZ TO BUILD OFFICE ...
ecs19 - Bill Ayers - RE-USE YOUR SHAREPOINT FRAMEWORK SKILLZ TO BUILD OFFICE ...ecs19 - Bill Ayers - RE-USE YOUR SHAREPOINT FRAMEWORK SKILLZ TO BUILD OFFICE ...
ecs19 - Bill Ayers - RE-USE YOUR SHAREPOINT FRAMEWORK SKILLZ TO BUILD OFFICE ...
 
O365: Attack of the Clones
O365: Attack of the ClonesO365: Attack of the Clones
O365: Attack of the Clones
 
Getting started with the PnP Provisioning Engine
Getting started with the PnP Provisioning EngineGetting started with the PnP Provisioning Engine
Getting started with the PnP Provisioning Engine
 
Introduction to Office 365 PnP- Reusable solutions
Introduction to Office 365 PnP- Reusable solutionsIntroduction to Office 365 PnP- Reusable solutions
Introduction to Office 365 PnP- Reusable solutions
 
All about Office UI Fabric
All about Office UI FabricAll about Office UI Fabric
All about Office UI Fabric
 
Branding Modern SharePoint
Branding Modern SharePointBranding Modern SharePoint
Branding Modern SharePoint
 
SharePoint Fest Chicago 2019 - From SharePoint to Office 365 Development
SharePoint Fest Chicago 2019 - From SharePoint to Office 365 DevelopmentSharePoint Fest Chicago 2019 - From SharePoint to Office 365 Development
SharePoint Fest Chicago 2019 - From SharePoint to Office 365 Development
 
SharePoint Saturday Calgary 2017 - From SharePoint to Office 365 Development
SharePoint Saturday Calgary 2017 - From SharePoint to Office 365 DevelopmentSharePoint Saturday Calgary 2017 - From SharePoint to Office 365 Development
SharePoint Saturday Calgary 2017 - From SharePoint to Office 365 Development
 
Use the PnP SharePoint Starter Kit to create your intranet in a box
Use the PnP SharePoint Starter Kit to create your intranet in a boxUse the PnP SharePoint Starter Kit to create your intranet in a box
Use the PnP SharePoint Starter Kit to create your intranet in a box
 
SharePoint Development with Visual Studio 2012
SharePoint Development with Visual Studio 2012SharePoint Development with Visual Studio 2012
SharePoint Development with Visual Studio 2012
 
Branding office 365 with front end tooling
Branding office 365 with front end toolingBranding office 365 with front end tooling
Branding office 365 with front end tooling
 

Similar to Build Your First SharePoint Framework Webpart

Similar to Build Your First SharePoint Framework Webpart (20)

How to convert your Full Trust Solutions to the SharePoint Framework (SPFx)
How to convert your Full Trust Solutions to the SharePoint Framework (SPFx)How to convert your Full Trust Solutions to the SharePoint Framework (SPFx)
How to convert your Full Trust Solutions to the SharePoint Framework (SPFx)
 
Deep dive into share point framework webparts
Deep dive into share point framework webpartsDeep dive into share point framework webparts
Deep dive into share point framework webparts
 
Introduction to Office Development Topics
Introduction to Office Development TopicsIntroduction to Office Development Topics
Introduction to Office Development Topics
 
How to convert your Full Trust Solutions to the SharePoint Framework (SPFx)
How to convert your Full Trust Solutions to the SharePoint Framework (SPFx)How to convert your Full Trust Solutions to the SharePoint Framework (SPFx)
How to convert your Full Trust Solutions to the SharePoint Framework (SPFx)
 
Introducción al SharePoint Framework SPFx
Introducción al SharePoint Framework SPFxIntroducción al SharePoint Framework SPFx
Introducción al SharePoint Framework SPFx
 
O365 Developer Bootcamp NJ 2018 - Material
O365 Developer Bootcamp NJ 2018 - MaterialO365 Developer Bootcamp NJ 2018 - Material
O365 Developer Bootcamp NJ 2018 - Material
 
SPUnite17 Building Great Client Side Web Parts with SPFx
SPUnite17 Building Great Client Side Web Parts with SPFxSPUnite17 Building Great Client Side Web Parts with SPFx
SPUnite17 Building Great Client Side Web Parts with SPFx
 
Convert your Full Trust Solutions to the SharePoint Framework (SPFx)
Convert your Full Trust Solutions to the SharePoint Framework (SPFx)Convert your Full Trust Solutions to the SharePoint Framework (SPFx)
Convert your Full Trust Solutions to the SharePoint Framework (SPFx)
 
CCI 2017 - Introduzione a SharePoint Framework (SPFx) - Fabio Franzini
CCI 2017 - Introduzione a SharePoint Framework (SPFx) - Fabio FranziniCCI 2017 - Introduzione a SharePoint Framework (SPFx) - Fabio Franzini
CCI 2017 - Introduzione a SharePoint Framework (SPFx) - Fabio Franzini
 
SharePoint Framework - Developer Preview
SharePoint Framework - Developer PreviewSharePoint Framework - Developer Preview
SharePoint Framework - Developer Preview
 
Convert your Full Trust Solutions to the SharePoint Framework (SPFx)
Convert your Full Trust Solutions to the SharePoint Framework (SPFx)Convert your Full Trust Solutions to the SharePoint Framework (SPFx)
Convert your Full Trust Solutions to the SharePoint Framework (SPFx)
 
Rock Solid Deployment of Web Applications
Rock Solid Deployment of Web ApplicationsRock Solid Deployment of Web Applications
Rock Solid Deployment of Web Applications
 
SPTechCon Austin 2019 - From SharePoint to Office 365 development
SPTechCon Austin 2019 - From SharePoint to Office 365 developmentSPTechCon Austin 2019 - From SharePoint to Office 365 development
SPTechCon Austin 2019 - From SharePoint to Office 365 development
 
CICD with SharePoint SPFx A useful overview
CICD with SharePoint SPFx A useful overviewCICD with SharePoint SPFx A useful overview
CICD with SharePoint SPFx A useful overview
 
M365 global developer bootcamp 2019 Intro to SPFx Version
M365 global developer bootcamp 2019 Intro to SPFx VersionM365 global developer bootcamp 2019 Intro to SPFx Version
M365 global developer bootcamp 2019 Intro to SPFx Version
 
Spsnyc transforming share point farm solutions to the add-in model and shar...
Spsnyc   transforming share point farm solutions to the add-in model and shar...Spsnyc   transforming share point farm solutions to the add-in model and shar...
Spsnyc transforming share point farm solutions to the add-in model and shar...
 
Real World SharePoint Framework and Azure Services
Real World SharePoint Framework and Azure ServicesReal World SharePoint Framework and Azure Services
Real World SharePoint Framework and Azure Services
 
SharePoint Fest DC 2019 - From SharePoint to Office 365 Development
SharePoint Fest DC 2019 - From SharePoint to Office 365 DevelopmentSharePoint Fest DC 2019 - From SharePoint to Office 365 Development
SharePoint Fest DC 2019 - From SharePoint to Office 365 Development
 
SharePoint Fest Seattle 2019 - From SharePoint to Office 365 Development
SharePoint Fest Seattle 2019 - From SharePoint to Office 365 DevelopmentSharePoint Fest Seattle 2019 - From SharePoint to Office 365 Development
SharePoint Fest Seattle 2019 - From SharePoint to Office 365 Development
 
Convert your Full Trust Solutions to the SharePoint Framework (SPFx) in 1 hour
Convert your Full Trust Solutions to the SharePoint Framework (SPFx) in 1 hourConvert your Full Trust Solutions to the SharePoint Framework (SPFx) in 1 hour
Convert your Full Trust Solutions to the SharePoint Framework (SPFx) in 1 hour
 

More from Eric Overfield

More from Eric Overfield (14)

Microsoft Ignite 2016 In Review
Microsoft Ignite 2016 In ReviewMicrosoft Ignite 2016 In Review
Microsoft Ignite 2016 In Review
 
The Future of SharePoint - What You Need to Know
The Future of SharePoint - What You Need to KnowThe Future of SharePoint - What You Need to Know
The Future of SharePoint - What You Need to Know
 
Branding SharePoint from Prototype to Deployment - Workshop
Branding SharePoint from Prototype to Deployment - WorkshopBranding SharePoint from Prototype to Deployment - Workshop
Branding SharePoint from Prototype to Deployment - Workshop
 
Create your own SharePoint Master Pages and Page Layouts
Create your own SharePoint Master Pages and Page LayoutsCreate your own SharePoint Master Pages and Page Layouts
Create your own SharePoint Master Pages and Page Layouts
 
Share point 2013 apps and i mean it
Share point 2013 apps and i mean itShare point 2013 apps and i mean it
Share point 2013 apps and i mean it
 
Your SharePoint 2013 Branding Initiation
Your SharePoint 2013 Branding InitiationYour SharePoint 2013 Branding Initiation
Your SharePoint 2013 Branding Initiation
 
Shape SharePoint 2013 for Mobile
Shape SharePoint 2013 for MobileShape SharePoint 2013 for Mobile
Shape SharePoint 2013 for Mobile
 
The 2013 Design Manager - From HTML to SharePoint
The 2013 Design Manager - From HTML to SharePointThe 2013 Design Manager - From HTML to SharePoint
The 2013 Design Manager - From HTML to SharePoint
 
The Design Dilemma of Mobile and SharePoint
The Design Dilemma of Mobile and SharePointThe Design Dilemma of Mobile and SharePoint
The Design Dilemma of Mobile and SharePoint
 
Integrating Search Driven Content in SharePoint 2013/2016/O365
Integrating Search Driven Content in SharePoint 2013/2016/O365Integrating Search Driven Content in SharePoint 2013/2016/O365
Integrating Search Driven Content in SharePoint 2013/2016/O365
 
Enhance SharePoint 2013 with Responsive Web Design
Enhance SharePoint 2013 with Responsive Web DesignEnhance SharePoint 2013 with Responsive Web Design
Enhance SharePoint 2013 with Responsive Web Design
 
Enhancing SharePoint with Responsive Web Design
Enhancing SharePoint with Responsive Web DesignEnhancing SharePoint with Responsive Web Design
Enhancing SharePoint with Responsive Web Design
 
Reshaping SharePoint for Evolving Internet Devices
Reshaping SharePoint for Evolving Internet DevicesReshaping SharePoint for Evolving Internet Devices
Reshaping SharePoint for Evolving Internet Devices
 
SharePoint Branding - Change Your Look
SharePoint Branding - Change Your LookSharePoint Branding - Change Your Look
SharePoint Branding - Change Your Look
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Build Your First SharePoint Framework Webpart

  • 1. BUILD YOUR FIRST SHAREPOINT FRAMEWORK WEBPART https://github.com/eoverfield/SPFx-Demos ERIC OVERFIELD | PixelMill Microsoft MVP & RD SharePoint Advocate & Enthusiast @ericoverfield
  • 2. ERIC OVERFIELD President & Co-Founder of PixelMill Microsoft MVP, Office Servers & Services Microsoft Regional Director Published SharePoint Author SharePoint Community Organizer & Contributor @ericoverfield ericoverfield.com
  • 3. PixelMill is a modern SharePoint Design Agency based in Northern California. On the forefront of web design trends since 1998, PixelMill provides innovative collaboration portals to enhance the user adoption of SharePoint intranets, extranets, and public facing sites. PIXELMILL @pixelmillteam pixelmill.com
  • 4. 1. SharePoint Framework (SPFx) Overview 2. SPFx Toolchain – the Build Environment 3. SPFx Webpart Components 4. Webpart Properties, Packaging & More OVERVIEW
  • 5. @ericoverfieldericoverfield.com HISTORY OF SHAREPOINT DEVELOPMENT MODELS 2013 APP/ADD-IN MODEL 2010 SANDBOX 2003 FULL TRUST 2016 CLOUD FRIENDLY SPFx
  • 6. A page and web part model with full support for client-side SharePoint development • Open source tooling / toolchain • nodeJS, npm, Yeoman, gulp, TypeScript, webpack and more • Easy integration with SharePoint data • Rest API wrapper classes • Available in the cloud and On-prem* • Generally available on SharePoint Online • On-prem availability scheduled for 2017 WHAT IS THE SHAREPOINT FRAMEWORK?
  • 7. SPFx – Welcome to integrated client-side rendering • Client-side rendering • No server side/compiled code / C# • IDE / Development platform agnostic • New / modern tool chain • nodeJS / Yeoman / Gulp / Reach / etc • Not dependent on JavaScript Injection • No iFrame • Direct integration with the page model HOW THE FRAMEWORK IS DIFFERENT
  • 9. THE SPFx TOOLCHAIN A DEVELOPMENT ENVIRONMENT
  • 10. • Office 365 / SharePoint Online tenant • App catalog for deployment • http://dev.office.com/sharepoint/docs/spfx/set-up-your-developer-tenant#create-app-catalog-site • Development workstation • PC / iOS / Linux – few limitations • Toolchain is open source – do not need a dedicated dev env • Much more simple than classic SharePoint Development PREREQUISITES
  • 11. • https://dev.office.com/sharepoint/docs/spfx/sharepoint-framework-overview • Use any most OS / workstation • Install nodeJS (current Long Term Support (LTS) version) • Yeoman and Gulp • C:> npm i –g yo gulp • SPFx Yeoman generator • C:> npm i –g @microsoft/generator-sharepoint • C:> npm update –g @microsoft/generator-sharepoint • Use code editor • VS Code / Sublime Text / NotePad++, etc A SHAREPOINT FRAMEWORK DEVELOPMENT ENVIRONMENT
  • 13. • C:> md helloworld-webpart • C:> cd helloworld-webpart • C:> yo @microsoft/sharepoint • Grab a cup of coffee – first time in a project, this will take a while • You can execute yo command again to add more webparts to project • Each addition of a webpart to a project will take much less time to scaffold • C:> gulp serve • Check out your first webpart! • It “should” be that simple • May also load in SPO workbench: https://”tenant”.sharepoint.com/sites/”site”/_layouts/15/workbench.aspx CREATE YOUR FIRST SPFx WEBPART
  • 15. WELCOME TO A NEW DEVELOPMENT PARADIGM
  • 16. WEBPART SOURCE OVERVIEW Get to know your Webpart folder structure • src: primary webpart TypeScript source code • config: json configuration files for build process • typings: TypeScript typings for JS libs – legacy • lib: Build files (TS compiled JS) ready for bundle • dist: Final web ready code for distribution • sharepoint: .spapp file for App Catalog • node_modules: NodeJS modules (JS) for toolchain
  • 17. @ericoverfieldericoverfield.com WEBPART PROPERTIES Webparts normally need custom properties • Webparts normally need custom properties • Define: /src/webparts/”webpart”/”webpart”Props.ts • Add in JSON • Default values: /src/webparts/”webpart”/”webpart”.manifest.json • Add in JSON: preconfiguredEntries.properties • Display: /src/webparts/”webpart”/”webpart”.ts • Method: protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {} • Override onchange: /src/webparts/”webpart”/”webpart”.ts • Method: public onPropertyPaneFieldChanged (propertyPath: string, oldValue: any , newValue: any) {}
  • 18. @ericoverfieldericoverfield.com ACCESS DYNAMIC DATA IN PROPERTY PANE • Method getPropertyPaneConfiguration returns a static IPropertyPaneConfiguration • Method does not allow for Promises / dynamic data • Solution: Load dynamic data within onPropertyPaneConfigurationStart() or onInit() then trigger pane refresh • this.context.propertyPane.refresh(); //cause pane to refresh with new data
  • 19. @ericoverfieldericoverfield.com CONNECT TO SHAREPOINT / DYNAMIC DATA • SPFx provides tools to quickly interact with external API data • TypeScript Http classes within @microsoft/sp-http • this.context always includes spHttpClient! • HttpClient • Basic set of features for REST operations with any external resource • SPHttpClient • REST calls against SharePoint • Handles context, security, etc. Could use HttpClient if desired import { SPHttpClient } from '@microsoft/sp-http'; this.context.spHttpClient.get(this.context.pageContext.web.absoluteUrl + `/_api/Lists/?$select=Id,Title&$filter=Hidden ne true`, SPHttpClient.configurations.v1) .then((response: SPHttpClientResponse) => { return response.json(); }); }
  • 21. PACKAGE YOUR WEBPART FOR DEPLOYMENT • Set deployment configuration • config/package-solution.json – general settings and package name • write-manifests.json – CDN / bundle location – for dev, can serve locally: gulp serve --nobrowser • C:> gulp clean (cleans sharepoint and temp folders) • C:> gulp build (Rebuilds the solution) • C:> gulp bundle (Creates the solution bundles) • C:> gulp package-solution (Creates /sharepoint/”webpart”.spapp) • C:> gulp –ship (minifies bundle and reads in CDN info from config/write-manifests.json) • C:> gulp package-solution --ship (Recreates /sharepoint/”webpart”.spapp with CDN info)
  • 22. PACKAGE YOUR WEBPART FOR DEPLOYMENT • After solution created, can then add to SharePoint • Add .spapp to app catalog • Add app to SharePoint site • Add webpart in site to content page • Webpart is still pointing to local host for JS • Configure CDN for full webpart deployment • https://dev.office.com/sharepoint/docs/spfx/web-parts/get-started/deploy-web-part-to-cdn • Or manually deploy solution bundle and config write-manifests.json
  • 24. CONNECT TO EXTERNAL LIBRARIES / FRAMEWORKS / RESOURCES • External libraries and component require Typings • i.e. for jQuery: • C:> npm install --save jquery • C:> npm install --save @types/jquery • Add to bundle – config/config.json "externals": { "jquery":"node_modules/jquery/dist/jquery.min.js“ }, • Within webpart • import * as myjQuery from 'jquery'; • Access: let $workspace: jQuery = myjQuery(‘#spPageChromeAppDiv');
  • 25. SPFx COMMAND REFERENCE • yo @microsoft/sharepoint // create a new base project • gulp serve // compile and start up local workbench • gulp serve --nobrowser // same as serve, but with no browser loaded • gulp package-solution // compile / create spapp file for redeployment in "Sharepoint" folder • gulp package-solution --ship // create minified component assets • gulp bundle // generate assets (js, css, etc) for deployment to CDN • gulp deploy-azure-storage // deploy assets to Azure storage as defined in config/deploy-azure- storage.json
  • 26. 1. Learn TypeScript! 2. Use SPHttpClient to connect to SharePoint • HttpClient for other API’s 3. Use frameworks and libraries that already has typings 4. Office UI Fabric available for consistent styling 5. Further Documentation Likely Exists • https://dev.office.com/sharepoint/docs/spfx/sharepoint-framework-overview RECOMMENDATIONS
  • 27. REVIEW 1. SharePoint Framework (SPFx) Overview 2. SPFx Toolchain – the Build Environment 3. SPFx Webpart Components 4. Webpart Properties, Packaging & More
  • 29. RESOURCES • SharePoint Framework documentation https://dev.office.com/sharepoint/docs/spfx/sharepoint-framework-overview • SharePoint Framework API https://dev.office.com/sharepoint/reference/spfx/sharepoint-framework-reference-overview • Build your first webpart https://dev.office.com/sharepoint/docs/spfx/web-parts/get-started/build-a-hello-world-web-part • Add properties to a SPFx Webpart https://dev.office.com/sharepoint/docs/spfx/web-parts/basics/integrate-with-property-pane • Connect a SPFx webpart to SharePoint Data https://dev.office.com/sharepoint/docs/spfx/web-parts/get-started/connect-to-sharepoint • Webpart with React and Office UI Fabric https://dev.office.com/sharepoint/docs/spfx/web-parts/get-started/use-fabric-react-components • Get an introduction to the SharePoint Framework https://channel9.msdn.com/Events/Ignite/2016/BRK2114-TS • Demo Source Code https://github.com/eoverfield/SPFx-Demos
  • 30. THANK YOU BUILD YOUR FIRST SHAREPOINT FRAMEWORK WEBPART

Editor's Notes

  1. Slides will be available from blog and twitter Look at introduction webpart for SPFx Who has looked at the framework? Anyone install it already? You have the dev tenant configured? 101 level overview. Good demos of options but going to limit how deep we go right now. Lots of valuable resources at the end to help you with your journey
  2. https://channel9.msdn.com/Events/Ignite/2016/BRK2114-TS
  3. http://dev.office.com/sharepoint/docs/spfx/sharepoint-framework-overview Key features of the SharePoint Framework include: Runs in the context of the current user and connection in the browser. There are no iFrames. The controls are rendered in the normal page DOM. The controls are responsive and accessible by nature. Enables the developer to access the lifecycle - including, in addition to render - load, serialize and deserialize, configuration changes, and more. It's framework agnostic. You can use any browser framework that you like: React, Handlebars, Knockout, Angular, and more. The toolchain is based on common open source client development tools like npm, TypeScript, Yeoman, webpack, and gulp. Performance is reliable. End users can use SPFx client-side solutions that are approved by the tenant administrators (or their delegates) on all sites, including self-service team, group, or personal sites. Solutions can be deployed in both classic web part and publishing pages and modern pages.
  4. http://sharepoint.handsontek.net/category/development/
  5. https://channel9.msdn.com/Events/Ignite/2016/BRK2114-TS
  6. NodeJS - root - current Long Term Support (LTS) version npm V3 npm -g install npm@3 On a PC, install windows-build-tools. will also install Python 2.7, needed for a few modules npm install --global --production windows-build-tools Need Yeoman generator npm i -g @microsoft/generator-sharepoint npm i -g @microsoft/generator-sharepoint@latest (to get latest)
  7. Look at developer tenant and dev env node –v gulp –v yo --generators code .
  8. Create our first SPFx webpart md helloworld-webpart cd helloworld-webpart yo @microsoft/sharepoint gulp serve Now open workbench in dev tenant, while local gulp is running
  9. Go to helloworld folder yo @microsoft/sharepoint --give a new webpart name gulp serve Also can load in SPO workbench /_layouts/15/workbench.aspx
  10. "jquery":"node_modules/jquery/dist/jquery.min.js", "jqueryui":"node_modules/jqueryui/jquery-ui.min.js"