SharePoint Coding in Few Lines - Xmas 2018
Xmas Gift 2018 from Thangu – SP Coding in Few Lines

Which scene is better? A simple village or a complex City? Few lines of coding is better than many lines of coding. Long ago, developers were paid for writing many lines of code and charged for a number of lines of code. Recently, even non-developers can achieve great things with tools like PowerApps, SharePoint Designer, InfoPath and SharePoint itself. However, these tools are complex and I was contacted many times to fix issues arising after developing solutions with these tools. Also, Microsoft may stop the support suddenly for certain tools like SharePoint Designer.
My little code solutions were the best since the code was working fine and I was never contacted to fix the issues arising from the small code. I was contacted to do code review for big applications which had 1000 lines of code in Visual Studio, written by many developers/a team. Too many cooks spoil the broth. Confusion and competition are bound to arise with complex codes. The goal of this blog is to list various ways to do more with few lines of coding with a simple tool like PowerShell. You are the only one coding and you are forced to do quality work. You spend less time on installing tools, learning new tools or fixing issues in tools and focus on the business logic.
Little code is better. I am concerned that many work(sometimes forced to work) for hours at a stretch in front of a computer and the eyes of every developer is in danger. Until an alternate and safe display system is found or the work hours and pressure is reduced for every software engineer, it is better to close the eyes and think to code, rather than type to code.
Column Formatting For SharePoint columns in SharePoint Online
You can get to the code box using
Select Column=>Column Settings=>Format this column=>Change the code=>Preview=>Save. For more information, visit here
You can change the background colour of a column code below:
Check the CSS1 column and click the image below to see more examples.
PowerShell One-Liners for Administrator
Administrators life is made easier with the help of simple PowerShell codes which are meaningful and self-explanatory. Imagine you are wanting to create a new site, your guess would match the answer below.
New-SPSite -Url “http://intranet.contoso.com/sites/demo” -Template “STS#0” -Name “Demo” -OwnerAlias “contoso\administrator”
You can view more examples from here which is a free preview from my SharePoint Pedagogy beta Book which mixes story, client conversations and code to get you to learn SharePoint better.
You can learn more on REST basics using PowerShell from here.
If you interested in the latest Microsoft Graph, check this out.
PNP PowerShell for SharePoint Online
PnP coding is simple and superb. Below is a code that creates new Website Site1
You can see more examples from here, which is a free preview of my SharePoint Pedagogy Gamma Book for budding developers.
You can see more examples from here.
Hope the above words help you achieve more with fewer lines of code. You can use the time saved from complex tools and large lines of code to celebrate the Xmas holiday season with loved ones. Wishing you a merry Xmas and a Happy New Year.
If you have read my blogs on CRUD in SharePoint in collab365, feel free to get certified in my recent “Simple SharePoint Crud Development with PowerShell” from here. (A Xmas offer) You can simply click Next, next and need not to worry about doing my Assignments and showing the output.
If you have not clicked the Xmas image at the top that takes you to various free codes, you access the link from here.
Register for my course from here :
https://www.udemy.com/simple-sharepoint-crud-development-with-powershell/learn/v4/overview
Why bother about Simple Code Solutions?

Few lines in SharePoint
My little code solutions were the best since the code was working fine and I was never contacted to fix the issues arising from the small code. I was contacted to do code review for big applications which had 1000 lines of code in Visual Studio, written by many developers/a team. Too many cooks spoil the broth. Confusion and competition are bound to arise with complex codes. The goal of this blog is to list various ways to do more with few lines of coding with a simple tool like PowerShell. You are the only one coding and you are forced to do quality work. You spend less time on installing tools, learning new tools or fixing issues in tools and focus on the business logic.
Little code is better. I am concerned that many work(sometimes forced to work) for hours at a stretch in front of a computer and the eyes of every developer is in danger. Until an alternate and safe display system is found or the work hours and pressure is reduced for every software engineer, it is better to close the eyes and think to code, rather than type to code.
How?
There are various ways to do coding with few lines. Here are some listed below:- Column Formatting For SharePoint columns in SharePoint Online – Use your CSS skills and create colourful and meaningful dashboards for your list. You can use conditional logic, add buttons to start a Flow, add borders, show a progress bar, align the text at the centre, give a round border and the limit is only your imagination.
- PowerShell One-Liners for Administrator – Are you an Administrator for SharePoint Server and do not want to contact developers to do many common tasks? There are around 500 commands in SharePoint through PowerShell. You can use them to accomplish many tasks like Creating new Web Applications, Sites, Lists from the shell itself.
- PowerShell PnP for SharePoint Online – Are you a developer/Power User who does not like to get permission from Administrator to install/get approval for Apps and want to do something fast. This can be done with very few lines in PnP PowerShell.
- REST queries – This way of coding from URL is simple and fantastic. You need to learn to construct the URL and have the power to do CRUD operations. You can get started by using the GET queries to get different data of your choice on various SharePoint objects like Lists, Libraries, Sites. The latest REST from Microsoft Graph is available for SharePoint. If you are new to REST, you can start using Graph Explorer and try GET, POST, PUT operations for Sites and List.
- CSOM – Are you a coder in C# and want to jump to coding without Visual Studio? You can use PowerShell and install the Client Components SDK and start accessing almost any object which cannot be done from the above techniques. You can do complex operations on Taxonomy, manage social feeds, users etc.
Examples
Examples are the best way to learn. Below are some code samples to help you understand. If you are interested in more examples for a certain code technique, detailed links are given.Column Formatting For SharePoint columns in SharePoint Online
You can get to the code box using
Select Column=>Column Settings=>Format this column=>Change the code=>Preview=>Save. For more information, visit here
You can change the background colour of a column code below:
Check the CSS1 column and click the image below to see more examples.
PowerShell One-Liners for Administrator
Administrators life is made easier with the help of simple PowerShell codes which are meaningful and self-explanatory. Imagine you are wanting to create a new site, your guess would match the answer below.
New-SPSite -Url “http://intranet.contoso.com/sites/demo” -Template “STS#0” -Name “Demo” -OwnerAlias “contoso\administrator”
You can view more examples from here which is a free preview from my SharePoint Pedagogy beta Book which mixes story, client conversations and code to get you to learn SharePoint better.
REST queries
Here is a sample REST query to get all lists in a Site. You append that to the site Url.You can learn more on REST basics using PowerShell from here.
If you interested in the latest Microsoft Graph, check this out.
PNP PowerShell for SharePoint Online
PnP coding is simple and superb. Below is a code that creates new Website Site1
You can see more examples from here, which is a free preview of my SharePoint Pedagogy Gamma Book for budding developers.
CSOM
CSOM is my personal favourite. I had enjoyed many Console Applications. Long back, a console application was attached to Windows Scheduler. The same functionality was achieved later with complex Timer Job. Now, we have Azure functions. I am recently using CSOM to get many Reports done to gather SharePoint data in a tabular format. Below is a CSOM code that displays the Location of your Site in SharePoint Online.You can see more examples from here.
Learn from my Mistakes
Save all your original code work in your GitHub. Think of an idea, and write one/two lines of code. Apply the code in Apps, Add-Ins, Workflows etc.- Do Error Handling
- Do null check
- Track the Start time and End Time
Hope the above words help you achieve more with fewer lines of code. You can use the time saved from complex tools and large lines of code to celebrate the Xmas holiday season with loved ones. Wishing you a merry Xmas and a Happy New Year.
If you have read my blogs on CRUD in SharePoint in collab365, feel free to get certified in my recent “Simple SharePoint Crud Development with PowerShell” from here. (A Xmas offer) You can simply click Next, next and need not to worry about doing my Assignments and showing the output.
If you have not clicked the Xmas image at the top that takes you to various free codes, you access the link from here.
Register for my course from here :
https://www.udemy.com/simple-sharepoint-crud-development-with-powershell/learn/v4/overview
Comments
Post a Comment