Saturday, August 7, 2021

What is PowerShell and why we use it?

 Ans:-

PowerShell is an automation scripting language from Microsoft

PowerShell is an automation scripting language. Therefore, most of the tasks that require many 'clicks' or are repetitive should be automated. PowerShell is used primarily for bulk actions, or complex automation tasks mixed with other files format like .csv, .json, or .XML, and will reduce most time consuming efforts in the long run.

If you need to create only one site collection, using PowerShell wouldn't really be beneficial.

you can change/remove them all at once on multiple sites, extract information like Users/Groups/Permissions, and even integrate with other platforms like Azure to automate your most complex tasks!

More examples where PowerShell is used:

Difference between forEach() and map() methods?

 Ans:-

1. The returning value

The forEach() method returns undefined and map() returns a new array with the transformed elements. 

const myAwesomeArray = [1, 2, 3, 4, 5]

myAwesomeArray.forEach(x => x * x)

//>>>>>>>>>>>>>return value: undefined


myAwesomeArray.map(x => x * x)

//>>>>>>>>>>>>>return value: [1, 4, 9, 16, 25]


2. Ability to chain other methods

map() is chainable. This means that you can attach reduce(), sort(), filter() and so on after performing a map() method on an array.


That's something you can't do with forEach() because, as you might guess, it returns undefined.


const myAwesomeArray = [1, 2, 3, 4, 5]

myAwesomeArray.forEach(x => x * x).reduce((total, value) => total + value)

//>>>>>>>>>>>>> Uncaught TypeError: Cannot read property 'reduce' of undefined

myAwesomeArray.map(x => x * x).reduce((total, value) => total + value)

//>>>>>>>>>>>>>return value: 55

What is SharePoint webhooks?

 Ans:-

SharePoint webhooks enable developers to build applications that subscribe to receive notifications on specific events that occur in SharePoint. When an event is triggered, SharePoint sends an HTTP POST payload to the subscriber. Webhooks are easier to develop and consume than Windows Communication Foundation (WCF) services used by SharePoint Add-in remote event receivers because webhooks are regular HTTP services (web API).

Currently webhooks are only enabled for SharePoint list items. SharePoint list item webhooks cover the events corresponding to list item changes for a given SharePoint list or a document library. SharePoint webhooks provide a simple notification pipeline so that your application can be aware of changes to a SharePoint list without polling the service. 

The following information is required for creating a new subscription:

  • Resource. The resource endpoint URL you are creating the subscription for. For example, a SharePoint List API URL.
  • Server notification URL. Your service endpoint URL. SharePoint sends an HTTP POST to this endpoint when events occur in the specified resource.
  • Expiration date. The expiration date for your subscription. The expiration date should not be more than 180 days. By default, subscriptions are set to expire 180 days from when they are created.

You can also include the following information if needed:

  • Client State. An opaque string passed back to the client on all notifications. You can use this for validating notifications, tagging different subscriptions, or other reasons.

What should I do to prepare for SPFx web part development?

 Ans:-

Here are some of the things that you can start doing in anticipation of SPFx web parts:

-Move all code to client side JavaScript as much as possible and using JSOM for all SharePoint transactions

-Change all server side code to make CSOM calls instead of in-process SharePoint API

-Start using Typescript wherever possible

-Convert full trust solutions to provider hosted add-ins wherever possible especially as web services which can be called from client side code

How do I complete tasks that require elevated permissions using SPFx web parts?

 Ans:-

All code that requires elevated permissions should be developed in provider hosted add-ins exposed as REST services which can be called from SPFx web parts.

How do I handle long running operations in SPFx?

 Ans:-

One way long running operations could be handled is using SharePoint web hooks on a list which stored the requests. SPFx web parts can simply update this list to initiate a long running operation with the web hook endpoint updating the list once the operation is done.

Can I use Angular with SPFx?

 Ans:-

Angular can be utilized through SPFx web parts although angular templates are not yet available for SPFx and thus setting up angular for use using SPFx takes are little bit more effort.