Monday, May 2, 2022

Retrieve more than 5000 items from SharePoint List

I actually have struggled with masses even as my list is getting large and want to retrieve the rows more than 5K. Here I located the answer is to apply the Recursive call to retrieve more than 5K items.


Here we're doing the recursive call to the GetListItems() function. This will fetch information withinside the bunch of a thousand objects and concatenate it to the response variable.

Here data.d.__next includes the URL to get the next set of items. In case we don’t have more items left to fetch, it'll not call GetListItems() function.


Hope many of us will find this helpful.

Friday, April 15, 2022

Getting an Access Token for SharePoint Online

Prior to SharePoint 2019, SharePoint Administrators, SharePoint Developers, and Power Users could use SharePoint Designer for no-code workflow development. With the release of SharePoint 2019 and SharePoint Online, modern process automation is developed through Microsoft Flow. SharePoint Online leverages modern tools, like PowerApps and Flow for forms and workflow deployment.

As with the SharePoint 2013 workflow, developers can execute REST calls to accomplish workflow actions. To test REST calls that will be executed in a Flow, a tool like Postman can be leveraged.  To successfully send REST calls, an access token will need to be obtained from Microsoft Azure Access Services. The below steps detail the process of obtaining an access token.

To begin, copy the text in the below box into a notepad.  This text is generalized headers for the body of the HTTP Post request to retrieve the token. The text in bold will be replaced as the steps to obtain the token are followed.

grant_type=client_credentials
&resource=00000003-0000-0ff1-ce00-000000000000/TENANT-NAME.sharepoint.com@TENANT-ID
&client_id= GENERATED CLIENT-ID@TENANT-ID
&client_secret= GENERATED CLIENT-SECRET

Step 1 Register an App

Navigate to https://[TENANT -NAME].sharepoint.com/_layouts/15/appregnew.aspx

  1. Open notepad
  2. Click Generate next to Client ID
  3. Copy the generated Client ID
  4. In notepad, replace the bold GENERATED CLIENT ID text with the copied generated client id
  5. Click Generate next to Client Secret
  6. Copy the generated Client Secret
  7. In notepad, replace the bold GENERATED CLIENT SECRET text with the copied generated client secret
  8. Update App Domain with google.com
  9. Update Redirect URL with https://localhost/
  10. Click Create

Step 2 Grant APP-Only permission to the APP

  1. Navigate to https://[TENANT-NAME].sharepoint.com/_layouts/15/appinv.aspx

Note: Client Id generated during APP registration appended with an @, followed by the Tenant ID

  1. Paste the value of “Client Id:” from the notepad in the App Id field
  2. Click Lookup
  3. Update the Permission Request XML: field the below values:
<AppPermissionRequests AllowAppOnlyPolicy="true"><AppPermissionRequest
Scope="http://sharepoint/content/sitecollection/web"
Right="Read"/></AppPermissionRequests>

 5. Click Create

Step 3 Get access token

  1. Navigate to Site Setting > App Permissions
    1. Locate the APP identifier that contains the Client Id generated during APP registration. The GUID on the right side of the @ is the Tenant ID. (You will need the Tenant ID in 3 places during the request build process)
      1. https://accounts.accesscontrol.windows.net/[Tenant ID]/OAuth/2
      2. Resource Header
      3. client_id Header

Update the Post Request Body in Notepad

In notepad, update the text as detailed below:

KeyValueNotes
grant_typeclient_credentials 
resource[SharePoint Online application principal ID]/[Tenant-Name].sharepoint.com@[Tenant-ID][SharePoint Online application principal ID] is always 00000003-0000-0ff1-ce00-000000000000

 

[Tenant-Name] with the tenant value as it appears in the sharepoint.com URL for the tenant

[Tenant-ID] was obtained on Site Setting > App Permissions

The GUID on the right side of the @ is the Tenant ID

 

The / and @ are literal values. Use them where specified

 

 

client_id[Client-ID]@[Tenant-ID]

 

Obtain this value by doing the following

Site Setting > App Permissions

Locate the APP identifier that contains the Client Id generated during APP registration. Copy everything to the right of | (pipe) character.

 

client_secretThe client secret that was generated during APP registration 

Build the Post Request URL

To obtain the access token, send a POST request to Microsoft Azure Access Control Service (ACS) account associated with Tenant. The URL is in the following format:

https://accounts.accesscontrol.windows.net/[Tenant-ID]/tokens/OAuth/2[Tenant-ID] was obtained on Site Setting > App Permissions

The GUID on the right side of the @ is the Tenant ID

 

  1. Open Postman
  2. Create a new Post Request
  3. Enter the updated ACS URL in the address field

Build the Post Request Header

KeyValue
Content-Typeapplication/x-www-form-urlencoded

Paste the Body Text

Copy the updated Body text from the notepad into the Body of the postman request.

View the Post Response

On success, the response body will contain an access-token key.

References

https://anexinet.com/blog/getting-an-access-token-for-sharepoint-online/

https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/add-in-permissions-in-sharepoint

https://docs.microsoft.com/en-us/sharepoint/hybrid/configure-server-to-server-authentication

Friday, January 28, 2022

Download SharePoint Online List items Attachments using PnP PowerShell

 Let’s download all attachments from a list. Following script creates a folder for every list object and downloads all attachments to the local disk.

Monday, January 3, 2022

Export HTML table to Excel

Code that will export html table to excel

Tuesday, December 21, 2021

13 Useful Websites You Wish You Knew Earlier

1. Vocalremover.org

Vocalremover separates the music from the vocals in with a powerful AI algorithm. Upload an mp3 file and let the algorithm do its job! The website also allows you to change the audio pitch without affecting the tempo and vice versa.

2. Unscreen.com

Are you looking for a tool that allows you to remove video background in a couple of clicks? With Unscreen you can remove or change the background from any video or GIF. You can search a GIF directly on the website or upload your own video.

3. Snapdrop.net

If you don’t own an iPhone —meaning that you don’t have AirDrop — you should definitely check Snapdrop out. Open the webpage both on your laptop and phone (the website will automatically connect the devices), drop the files you want to transfer, and they’ll appear on the other device ready to be downloaded. Easy!

4. Smartmockups.com

Create free mockups for any device and physical product! Smartmockups.com is a web app that allows you to generate high quality mockups for your next presentation, website, social media campaign, portfolio and more. To access the service you need an account.

5. Panzoid.com

Do you need video intros, outros, or end screens? This is a great website if you have a YouTube channel and need this type of video material. There are hundreds of templates submitted by the users of the websites. Understanding how this website works might take a few minutes, but it’s surely worth it! Side note: it’s more compatible with Chrome than Safari.

6. Midomi.com

Do you ever think of a song but don’t know the title or how the lyrics go? If yes, Midomi is what you need! Just hum the words and this website will find the song for you.

7. Kamua.com

If you are looking to resize, cut, and caption videos for TikTok or Instagram Reels, this tool is a must have. Transform any horizontal video into a dynamic vertical with this smart tool. You need an account to access the service.

8. Justtherecipe.app

If you love cooking this is the website for you. Sometimes, when you browse recipes online you have to skim through five paragraphs before you can find the actual recipe. With Just The Recipe, you just need to paste the url of the page into the web page, and it will show you the list of the ingredients and the instructions on how to make that food, with no distractions.

9. Jitter.video

Jitter Video is motion design made simple. With this tool, you can create custom motion graphics for free; just select the template you like and start editing! You need an account to access the service.

10. Loading.io

With Loading, you can make simple animations, create loading patterns and backgrounds, and design progress bars. If you need simple animated visual elements, this tool is for you. It might not have the prettiest UI but it sure does its job.

11. Shortlyai.com

What if someone told you that you can write an article without actually writing anything? It’s possible with AI. Go to Shortlyai, pick a topic, choose an output length, input a brief, and the AI will write for you. The service is not free and requires you to have an account.

12. Renderforest.com

This branding platform allows you to create intro and music visualisations. Search through customisable templates and find the one you like. Add your logo, tagline, music, and export! Renderforest helps you create a variety of branded material with minimal time and effort — from videos to logos, mockups, and websites. To access the platform you need to create an account.

13. Naturalreaders.com

This Text-to-Speech tool (TTL) converts any text to audio, allowing you to choose from a variety of voices and accents. You can also download the audio file as mp3, so that you can listen anytime, without Internet connection. This tool is also useful if you need an easy-to-use TTL tool for your Instagram Reels — since Instagram lacks the TTL function TikTok has.


Tuesday, December 14, 2021

Convert Number, String, Float and Format JSON

 1) Convert to String

To quickly convert a number to a string, we can use the concatenation operator (+) plus followed by an empty set of quotation marks "" .

let val = 1 + "";
console.log(val); // Result: "1"
console.log(typeof val); // Result: "string"

2) Convert to Number

The opposite can be quickly achieved using the addition operator + .

let int = "15";
int = +int;
console.log(int); // Result: 15
console.log(typeof int); Result: "number"

This may also be used to convert Booleans to numbers, as below:

console.log(+true);  // Return: 1
console.log(+false); // Return: 0

3)Quick Float to Integer

If you want to convert a float to an integer, you can use Math.floor() , Math.ceil() or Math.round() . But there is also a faster way to truncate a float to an integer using |, the bitwise OR operator.

console.log(23.9 | 0);  // Result: 23
console.log(-23.9 | 0); // Result: -23

4)Format JSON Code

Lastly, you may have used JSON.stringify before, but did you realise it can also help indent your JSON for you?
The stringify() method takes two optional parameters: a replacer function, which you can use to filter the JSON that is displayed, and a space value.
The space value takes an integer for the number of spaces you want or a string (such as '\t' to insert tabs), and it can make it a lot easier to read fetched JSON data.

console.log(JSON.stringify({ alpha: 'A', beta: 'B' }, null, '\t'));
// Result:
// '{
//     "alpha": A,
//     "beta": B
// }'

Monday, December 13, 2021

Get Query Params

window.location object has a bunch of utility methods and properties. We can get information about the protocol, host, port, domain, etc from the browser URLs using these properties and methods. 


var args = window.location.search
let data = new URLSearchParams(location.search).get('reqId');
console.log(data)