Showing posts with label Customization of SharePoint. Show all posts
Showing posts with label Customization of SharePoint. Show all posts

Saturday, 23 April 2022

Power Automate Convert SharePoint List Items to Modern Pages By Sabeeh

 Convert Bulk Custom list data to Modern Page using Power Automate


Automation to Create Modern Pages

Custom List Entry
Power Automate Created Page


Scenarios Problem:

1: Creating manual pages takes time, entry in custom list will save your time to create page.

2: Like if you migrated content from SharePoint on premises custom list to SharePoint online and you want to convert this list data to modern pages experience. So you are right article.

Perquisites:

Following are very basic steps as perquisites:

1: Create a list with desired columns so data can be converted to Modern page.

2: Create Page template in modern view

3: Create Power automate to get data from list and create Modern page as per page template.

Step 1: Create a Custom List

Columns depends on the data you want to map on Template I created Features, Potential user cases and Point of contact. List Name: Posts

SharePoint list fields

Step 2: Create a Template

Now create a new page in SitePages this page will be utilized as Benchmark to map list data. PageTemplate.aspx I have created.

Enter Placeholders using text editor so we can search these where list column should mapped. You can add as many you want I have added 3 only.

·         [**ListColumn 1**]

·         [**ListColumn 2**]

·         [**ListColumn 3**]

Final Look of Template PageTemplate.aspx:

    

Final Look of Template


When we edit the SharePoint page and publish a request sent in background. This request we can find in Network tab by following below points:

1.       Go to template page we created (PageTemplate.aspx)

2.       Press F12 for Developer tool

3.       Go to Network tab

4.       Edit this template page and publish it

5.       In Network call there will be a action SavePage like below

Developer tool to get Response


Step 3: Click on view source:

Right click here and click show more then copy the complete content.

Copy Page Response

Paste your content inside visual studio code and search for listcolumn we will use below content in Power automate to create new page and map content with listcolumn fields.

Visual studio code replace Column placeholder

Step 4: Create the Power Automate

  • Power Automate Action On Item Creation

Create a Power automate on top of custom SharePoint list we created at step 1 on item creation (Post List).

Power Automate Action

  • Copy Template.aspx as New Page:

Now we have to copy PageTemplate.aspx to use as new page. To create new page using template there is Rest endpoint call CopyTo. We will use custom list title as new page name in URI field like below.

/_api/web/getfilebyserverrelativeurl(‘/sites/SitePages/PageTemplate.aspx’)/copyto(‘/sites/SitePages/@{triggerBody()?[‘Title’]}.aspx’)

CopyTo Action to Create New Page

  • Checkout newly created Page:

After above action new page will be created in sitepages. But to modify we have to check out this page after making changes we will check in again. To achieve this we need Page ID there is action in power automate Get file metadata like below but make sure you replaced forward slash with %2f


Check Out newly created Page

Using get file metadata we have Page ID to check out the page we have to run another send an http request like below using CheckOutPage action:

_api/sitepages/pages(@{body(‘Get_file_metadata’)?[‘ItemId’]})/CheckOutPage         


Page Checkout action

  • Compose Action to Replace Spaces

Note: if you have multiline columns in custom list we created above there are chances of line breaks but json only understand </br> tag for line breaks. To convert line breaks to </br> we have to compose action and URI component. Our list is having 2 multi lines text columns so we have to use 2 Compose like below:

Compose 1:

uriComponentToString(replace(uriComponent(triggerBody()?[‘Features’]), ‘%0A’, ‘</br>’))

Compose 2:

uriComponentToString(replace(uriComponent(triggerBody()?[‘Potentialusercases’]), ‘%0A’, ‘</br>’))

 

Compose to remove spaces

  • Draft Page Action:

By creating 3rd HTTP request to SharePoint we can save page as draft using below URI:

_api/sitepages/pages(@{body(‘Get_file_metadata’)?[‘ItemId’]})/savepageasdraft

In this part we will add response by copying from visual studio or from Response body browser developer tool. Paste this response in Body of http request action and search ListColumn and Page title. Replace page title with title from When an item created action.

Paste Response From Visual studio or Developer Tool

                                   

Draft Page Call

Now search ListColumn and replace multiple columns with Compose outputs.

Features= outputs(‘Compose’)

Potential user cases = outputs(‘Compose_2’)

Point of contact = @{triggerOutputs()?['body/PointofContact/Email']} (from item creation action)



Following is final look after modifications:




  • Publish Page

Once done with changes create another http request to publish the page.
Publish Newly created page Action


Now just save your Power Automate and create new entry in SharePoint Custom list.

Summary Total Actions


Thank for reading this article I hope this helps you. if you stuck somewhere please feel free to reach me in comments or through email: SabeeSharif@gmail.com

#SharingIsCaring #SharePointEnvrionment #PowerPlatform #SharePointOnline #ProblemSolution #PowerPlatfromLearning #SharePointLearning























Thursday, 26 January 2017

Final Year Project Ideas in SharePoint.

Don't worry by reading these names, things are very easy just study once. If you are looking for to select FYP you may develop any of this module using any technology. Like Content Management System, Business Workflows etc.

SharePoint Functionalities:


SharePoint is Combination of these given fields:
1: Content Management System
2: Business Workflows
3: Indexing and Search
4: Enterprise Integration & Collaboration
5: Business Intelligence
6: Portals


1: Content Management System:

SharePoint as Content Management System, CMS have these basic functionalities so you will get these all in SharePoint.

As per my this blog SharePoint As Document Management System i have explained regarding Document Management System but SharePoint not only save documents but also any kind of Content like pdf, Excel, images, HTML etc. So SharePoint is Content Management System. SharePoint have all these above functionalities create content of any type then measure quality, storage space etc then develop means save this content, optimize if created content is working efficiently or not. Deliver this content to production. Manage this content to control visibility or other operations like Create, Update or Delete Permissions. In future if you need to update this content you can do it easily.
You can also integrate workflows with these operations to perform specific task on specific conditions. 


Thanks for your time. If you will have any query feel free to comment here. Thanks

Tuesday, 24 January 2017

What you should know before Development of SharePoint?

Although Architecture for SharePoint to access list or file of Document Library define in this image:

but in code you have to access first site then Open web.
Get SharePoint List Using C# code:
In this tutorial we will learn how to get Document Library files by traversing SharePoint Architecture.
SharePoint Architecture to access any list:
SecurityPrevillages-> Site(ByProvidingURL) ->Web -> List (like DocumentLaibrary) -> Get Files under Document Library

Steps:
1: Create Console Application using C# etc then add this library "using Microsoft.SharePoint".
2: Get the path of site which library files you want access in your code like (string baseUrl = "http://sp2013:81/sites/sis/";)
3:  Security Check if you are running this utility on same server where SharePoint is deployed. Get Security check by adding this line SPSecurity.RunWithElevatedPrivileges(delegate() {  //YourCOde });
4: Then Get site where you want some changes or want to get something from existing applications like Document Library.
5: Get all uploaded documents on document library by passing library name as a parameter in   SPDocumentLibrary lib = (SPDocumentLibrary)web.Lists[LaibraryName];
6: using Lib.RootFolder to get all files existing in this folder.
This is Generic Function written in C# to access all documents from a specific Library:
public static bool getAllDocuments(String LaibraryName)
{
Console.WriteLine("getAllDocuments debug, START");
bool isOK = false;
string baseUrl = "http://sp2013:81/sites/sis/";
try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(baseUrl))
{
using (SPWeb web = site.OpenWeb())
{
SPDocumentLibrary lib = (SPDocumentLibrary)web.Lists[LaibraryName]; //Get All documents with name
//SPDocumentLibrary lib = (SPDocumentLibrary)web.Lists["Client Incoming Correspondence"]; //Get All documents with name

IEnumerable<SPFile> allFiles = ExploreFolder(lib.RootFolder);
foreach (SPFile file in allFiles)
{
Console.WriteLine("getAllDocuments debug, File Name : " + file.GetType());
string filename = file.Name;
Console.WriteLine("getAllDocuments debug, File CharSetName : " + file.CharSetName);
Console.WriteLine("getAllDocuments debug, File SourceLeafName : " + file.Title);
string strFileExtension = new FileInfo(file.Name).Extension;
string strFileUrl = file.Url;
Console.WriteLine("strFileUrl : " + strFileUrl);

}

}
}
});
}
catch (Exception e)
{
Console.WriteLine("getAllDocuments debug, " + e.Message);
isOK = true;
}
Console.WriteLine("getAllDocuments debug, END");
return isOK;
}
By using this approach you can access any list. Thanks for reading this blog if you need any help feel free to comment here. Thanks