Event receiver | Workflows |
1) Event receivers in SharePoint can be executed before or after an operation, like before adding an item or after adding an item. | 1) workflows can be executed only after the operation happed like after an item added to the list or after an item update. |
2) The event receivers in SharePoint 2013 or event receivers in SharePoint 2016 cannot be launched manually. They always attached to a SharePoint object which will run automatically when the event occurs. | 2) workflows can be started automatically as well as can be started manually also. |
3) You can cancel the operation like adding an item | 3) You cannot cancel the action as the item is already added. |
4) You can create an event receiver only in Visual Studio | 4) You can use any tool like SharePoint designer, Visual Studio, Visio, 3rd party apps, etc. |
5) No UI interaction | 5) Can use forms like initiation form, association form, etc. |
6) Can be run for a very short period of time. | 6) Can run for days, weeks or even years. |
7) Will not survive after server reboots | 7) Will survive after server reboots |
Monday, June 8, 2020
Difference between event receiver and workflow?
What are Event Receivers ans its types?
What is the difference between SharePoint Online and SharePoint On-premise?
Online | On-premise |
1) No need of hardware to buy. All updates and patches are taken care by Microsoft | 1) Resource requirement: you need more resources to maintain the server, to add updates and patches. This means a requirement of more people and hardware. |
2) Information stored in the cloud | 2) Information lies in your local environment |
3) Cost is less and is billed monthly per user. | 3) Cost is more as it requires more resources, hardware, and maintenance |
4) Powershell control is reduced as compared to on-premise. | 4) More PowerShell control |
What is the difference between Sharepoint-hosted apps and Provider-hosted apps?
Sharepoint-hosted apps | Provider-hosted apps |
No server-side code, 100% client-side code | Server-side coding is used. Managed code and high trust |
Can be developed using HTML5, CSS, JavaScript, jQuery, ASP.NET Ajax, CSOM, REST API, Silverlight, KnockOut JS, Angular JS | Any programming language can be used |
Data Storage Locations: SharePoint Online, Content Database | Data Storage Locations: ISV Storage, Azure Storage, Content Database. |
Can be hosted on either SharePoint on-premises or office 365 | Deployed outside the SharePoint farm |
What is App-model in SharePoint and its types?
- SharePoint hosted apps
- Provider-hosted apps
SharePoint hosted apps are those apps, where all the components are hosted on SharePoint only.
SharePoint-hosted apps are installed on a SharePoint website, called the host web. They have their resources hosted on an isolated subsite of a host web, called the app web.
Provider Hosted App
Provider-hosted apps for SharePoint include components that are deployed and hosted outside the SharePoint farm.
They are installed to the host web, but their remote components are hosted on another server. i.e. App web for provider hosted apps is completely a different server (provider).
What is the SharePoint Document Library?
What is SharePoint List?
What is a Content type?
What is Site Column?
Difference between list and library in SharePoint?
How to add custom .css and .js file in SharePoint master page?
How to Customize List View in SharePoint Online using JSLink?
JSLink is a new approach combining JavaScript, HTML and CSS elements to customize the look of a SharePoint list views, list forms, and can control the rendering of fields. JSLink was introduced in SharePoint 2013.
The power of using JSLink is that it uses JavaScript and runs in the client and you can use all the powerful JavaScript libraries and for its easy to debug.
In this example, we are going to customize view of task list. Task list has default column with internal name PercentComplete. This column stores %age task completion, we will add conditional formatting to this column.
Default View:
Final View:
Steps to do it?
Step 1: Create a JavaScript code file to override default view
Step 2: Upload JavaScript file to Master Page Gallery –> Display Templates folder
Step 3: Set JS Link Property of List view web part to Url of uploaded JavaScript file.
Step 1: Create a JavaScript code file to override default view
In the first step, we need to develop the JavaScript code file that will contain the customization logic.
Simple example:
The following code shows a simple function that will display description field in the list in italics.
(function () {
var overrideCtx = {};
overrideCtx.Templates = {};
overrideCtx.Templates.Fields = {‘Description’: { ‘View’: ‘<i><#=ctx.currentItem.Description#></i>’ }
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();
overrideCtx variable holds the current context of the list item.
Templates.Fields property provides access to individual list fields.
RegisterTemplateOverrides function call registers the templates for your list to use.
Main Code to customize PercentComplete column in task list
CustomizeTaskCompletionView.js
(function () {
// Initialize variable that will store overrides objects.
var overrideCtx = {};
overrideCtx.Templates = {};
overrideCtx.Templates.Header = “”;
overrideCtx.Templates.Footer = “”;
overrideCtx.Templates.Fields = { ‘PercentComplete’: { ‘View’: CustomProgressBar } };
// Register template overrides.
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx); })();
function CustomProgressBar(ctx) {
var percentage = ctx.CurrentItem.PercentComplete;
var percentageNr = ctx.CurrentItem.PercentComplete.replace(” %”, “”);
var duedate = new Date(ctx.CurrentItem.DueDate);
var color = getCompletion(percentageNr, duedate);
return “<div style=\”background: #F3F3F3; display:block; height: 15px; width: 120px;\”><div style=\”background: ” + color + “; height: 100%; width: ” + percentageNr + “%;\”></div></div> ” + percentage + “”;
}
function getCompletion(progress, duedate) {
var datenow = new Date();
if (parseInt(progress) < 100 && duedate.getTime() < datenow.getTime())
return “Red”;
else
return “Green”;
}
Step 2: Upload JavaScript file to Master Page Gallery à Display Templates folder
Navigate to Site Settings –> Master Pages and page layouts –> Display templates folder
Upload JavaScript file CustomizeTaskCompletionView.js created in step 1 to this folder.
Content type –> JavaScript Display Template
Target Control Type –> View
Standalone –> Override
Target Scope –> /
Step 3: Set JS Link Property of List view web part to Url of uploaded JavaScript file.
Navigate to Task list and edit list view WebPart, I have opened Workflow Tasks list
You will see JSLink property under Miscellaneous section
If JSLink property is missing, In Office 365, go to your SharePoint Admin Center –> Settings and enable custom script.
It may take upto 24 hours before you start seeing JSLink property once you enable it.
Once property is visible, provide uploaded JavaScript URL. We cannot give absolute path, we will have to use site collection token representation like this:
~sitecollection/_catalogs/masterpage/Display Templates/CustomizeTaskCompletionView.js
~sitecollection The URL of the parent site collection of the current website.
Save changes and add new task to this list. It will look like this:
Friday, June 5, 2020
What are Webparts and Webpart Zones?
What are Master pages and Page layout in SharePoint?
What are Application Pages, Site Pages and Content Pages?
What is a Site definition and Site Template?
Can we create Web Application in SharePoint Online?
What is the difference between Authentication and Authorization in SharePoint?
- Windows authentication
- Forms-based authentication
- SAML token-based authentication
Why we should go for SharePoint framework or its benefits?
- It runs in the user context so only the allowable data content will be displayed to an end-user.
- It is light-weight, fast and responsive as SPFx is completely a client side and uses NodeJS. It is compatible with the Office Fabric UI components and becomes responsive.
- When the server-side solutions are not used wisely, they might cause a damage from a site collection to an entire SharePoint farm. One can mitigate this risk using the client-side development which is supported by the SPFx.
- If one’s online tenant is either running on the old SharePoint 2013 classic mode or upgraded to latest tenant feature, then one can have a back seat and relaxed as the SPFx is compatible with both the modern as well as classic pages.
- In the erstwhile client-side code, one is required to use some extra variables and make some calls for fetching the configurations. Now, this becomes very convenient to use with the SPFx as one can assign the properties of a custom client-side web-parts and configure it accordingly.
- The SPFx provisions its own deployment mechanism which includes the app bundling, the app packaging, the app shipping to store (or to local SharePoint App Catalog) and deployment in the tenant with the proper permission. The whole process is managed in better way for the client-side web parts.
- If one is not having internet connection, then also one can develop on the SPFx coming with a local workbench which is effective in developing and testing of a client-side web-parts.
- It is scalable as not being limited to SharePoint. One can use NodeJS and other component available in NodeJS community in the SPFx client-side development. A client-side web part can be made to interact with Office365, Azure, One Drive, Outlook, etc. with the Microsoft Graph API development.
- No specific machine related requirement is necessary for the development. One can use any machine-like Windows, Mac or Linux for the client-side development. The only necessity is to set-up the development environment through NodeJS, Gulp and Yeoman template installation of the framework. To develop SPFx web-parts, one is simply required having any text editor.
- The business logic or code of a client-side web-part is secured as it can’t be accessed from the page source or browser inspect.
How to deploy the spfx webpart?
- Launch the console window and set console path to our SPFx web part directory. If Yeoman server is running on a console you have to stop it by Ctrl+C command followed by Y.
- gulp clean command: This command clean the project deployment file .sppkg which is present in folder sharepoint under project directory and also creates debug solution file.
- gulp bundle –ship command: This command help to create minified files for build the solution and also generate debug bundle under dest folder. This builds the minified assets required to upload to the CDN provider. The minified assets can be found under the temp\deploy directory.
- gulp package-solution –ship command: This creates the updated client-side solution package in the sharepoint\solution folder. Created file: sharepoint\solution\ms-hello-world.sppkg
- Now upload or drag an drop solution package file from sharepoint\solution\ms-hello-world.sppkg to App for sharePoint library in app catalog site.
- Once our SPFx web part package has finished uploading, we will be prompted with a dialog window to complete the deployment. This is where you will choose whether to deploy to all sites within your tenant or to all subsites within your site collection. Make your selection and then click the Deploy button.
- We have deploy our Hello World SPFx web part. Now we need to add it on modern SharePoint site page.
- From + Add a new web part icon we select our WP Hello World web part and save it.
How we can use SharePoint framework client side webpart in classic pages?
What is Redux?
- Redux is a predictable state container for JavaScript applications.
- It helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test.
- Simply put, Redux is a state management tool. While it’s mostly used with React, it can be used with any other JavaScript framework or library.
- It is lightweight at 2KB (including dependencies), so you don’t have to worry about it making your application’s asset size bigger.
- With Redux, the state of your application is kept in a store, and each component can access any state that it needs from this store.
Thursday, June 4, 2020
What is the difference between local workbench and Actual site workbench?
- One is outside of SharePoint, hosted locally on the development machine that runs offline without SharePoint access and SharePoint data.
- This allows the team and designers to build and design solutions with mock or fake data to focus on the user interface.
- This enables us to quickly test the web part without deploying in SharePoint.
- This includes the client-side page and the client-side canvas in which we can add, delete, and test our web part in the development phase.
- When we execute the “gulp serve” command the local workbench starts. This command executes a series of gulp tasks to create a local, node-based HTTPS server on localhost:4321 and launches our default browser to test web parts from our local dev environment.
How you handle multiple textbox values on single handler in react js?
How we can get current site url in Sharepoint framework?
Why we use constructor() and super() in class?
- The constructor is a method that’s automatically called during the creation of an object from a class.
- It can be used to bind event handlers to the component.
- It can be used for initializing the local state of the component.
- The constructor() method is fired before the component is mounted.
- When you call the super() method, it calls the constructor of the parent class which in the case of a React component is React.Component
super() is called inside a react component only if it has a constructor. For example, the below code doesn't require super:
class App extends React.component {
render(){
return <div>Hello { this.props.world }</div>;
}
}
However if we have a constructor then super() is mandatory:
class App extends React.component {
constructor(){
console.log(this) //Error: 'this' is not allowed before super()
}
}
The reason why this cannot be allowed before super() is because this is uninitialized if super() is not called. However even if we are not using this we need a super() inside a constructor because ES6 class constructors MUST call super if they are subclasses. Thus, you have to call super() as long as you have a constructor. (But a subclass does not have to have a constructor).
We call super(props) inside the constructor if we have to use this.props, for example:
class App extends React.component{
constructor(props){
super(props);
console.log(this.props); // prints out whatever is inside props
}
}
What is props and state in react
Props
- The props are read-only properties we set values to when we call our React component.
- They are a way to transfer information from the parent component to the child.
- We can also use them in your React component to control how it behaves in different situations – when different kind of data is passed down to it.
- The state can also be used for controlling, e.g., how our component is rendered.
- What makes state different from props is that we can change its values.
- We typically initialize state with null values in the constructor and later change the values when something happens in the component to reflect that change – the new state of the component.