Showing posts with label Amir Reza. Show all posts
Showing posts with label Amir Reza. Show all posts

Monday, March 21, 2016

Often used PowerShell Command for SharePoint Administrator.

PowerShell is vital governance tools for SharePoint.

These are the some PowerShell commands Every Administrator Should know.

Add PowerShell to ISE.

Command:  Add-PSSnapin Microsoft.SharePoint.PowerShell

1. Find an error from Correlation ID.

Command:  get-splogevent | ?{$_.Correlation -eq "<Correlation ID>"} | select  Category, Level, EventID,Message | Format-List > C:\Correlationerror.log

This Command list error message with Category, Level, EventID, Message in “C” drive by correlationerror name in notepad

2. Creating Site collection.

Command:  New-SPSite -Url "Your site url" -Name "MyTesting Site" -Template "STS#0" -OwnerAlias "Domain\owner" -Language 1033

This example creates an English site collection owned by owner with Team Site Template. Lots of parameter can add as per requirement.

3. Restore a deleted site collection.

Command:  Get-SPDeletedSite

This command lists all deleted site with WebApplicationId, DatabaseID, SiteSubscriptionID, SiteID, Path, Scheme, Url, DeletionTime parameter.

Restore-SPDeletedSite –Identity SiteID

Find Respective SiteID of deleted site collection from Get-SPDeletedSite

 and replace it to Restore-SPDeletedSite –Identity SiteID.

4. Export SharePoint List and library.

Command:  export-spweb -identity http://mytestsite -path c:\listName.cmp -itemurl   /Lists/EmployeeDetails –includeusersecurity  

http://mytestsiteà site collection name.

EmployeeDetails à List name.

c:\listName.cmp à save In C drive by listName with .cmp Extention.

5.Import SharePoint List

Command:  Import-SPWeb -identity "http:// mytestsite " -path c:\listName.cmp –force

"http:// mytestsite "  is Site collection name where have to  import.

c:\listName.cmp is path from where we have to import listName.

6. Backup SharePoint Site Collection.

Command:  Backup-SPSite –Identity http://MySiteCollection/ -Path C:\Backup\MysiteCollection.bak -Verbose

Note: Verbose use to see progress

7. Restore SharePoint Site Collection.

Command:  Restore-SPSite –Identity http://MySiteCollection/ -Path C:\Backup\MysiteCollection.bak -Force -Verbose

8. Backup SharePoint Farm

Command:  Backup-SPFarm -BackupMethod Full –Directory C:\FarmBackup\SPFarm

Note: Above command Backups the entire database.

             Or

Command:  Backup-SPFarm -BackupMethod Differential –Directory C:\FarmBackup\SPFarm

Note: Backs up only the changes made to the database since the last full backup. The differential backup method cannot be used to back up Index databases or Document Libraries. The Full backup method must be used to back up these resources

9. Restore SharePoint Farm

Command:  Restore-SPFarm -Directory C:\FarmBackup -RestoreMethod overwrite

10. Add Solution àAdds a SharePoint solution package to the farm.

Command:  Add-SPSolution C:\customsolution.wsp

C is directory and customsolution.wsp  is solution name.

11. Install SharePoint Solution  à Deploy the SharePoint Solution in the Farm.

Command:  Install-SPSolution –Identity customsolution.wsp –WebApplication http://webapplicationsite  –GACDeployment

Note: If you are using the GAC or Code Access Security, Specify  either –GACDeployment or –CASPolicies.

 –WebApplication parameter applies for particular web application.

 If have to apply for all web application use –AllWebApplications (Hope manifest allow this) Or don’t add –WebApplication parameter. You can also use –Force parameter to force the deployment.

12. Uninstall SharePoint solution

Command:  Uninstall-SPSolution –Identity customsolution.wsp –WebApplication http://webapplicationsite

13. Update SharePoint Solution

Command:  Update-SPSolution –Identity customsolution.wsp –LiteralPath C:\customsolution.wsp –GACDeployment

14. Remove SharePoint Solution.

Command:  Remove-SPSolution –Identity customsolution.wsp

15. Uploads a new sandboxed solution package to the solution gallery.

Command:  Add-SPUserSolution –LiteralPath c:\customsandboxsolution.wsp –Site http://mysitecollection

16. Deploy Sandboxed solution.

Command:  Install-SPUserSolution –Identity customsandboxsolution.wsp –Site http://mysitecollection

17. Upgrade existing Sandboxed solution.

Command:  Update-SPUserSolution –Identity customsandboxsolution.wsp –Site http://mysitecollection ToSolution customsandboxsolution2.wsp

18. Uninstall Sandboxed Solution.

Command:  Uninstall-SPUserSolution –Identity customsandboxsolution.wsp –Site http://mysitecollection

19. Remove Sandboxed solution package from the solution gallery.

Command:  Remove-SPUserSolution –Identity customsandboxsolution.wsp –Site http://mysitecollection

20. Enable SharePoint Features

Command:  Enable-SPFeature –Identity FeatureNameOrGUID –Url http://your site name

21. Disable SharePoint Features

Command:  Disable-SPFeature –Identity FeatureNameOrGUID –Url http://your site name


by Amir Reza via Everyone's Blog Posts - SharePoint Community

Saturday, March 19, 2016

SQL Server 2014 Installation on Windows Server 2012 R2 for SharePoint

Step By Step SQL Server 2014 Installation for SharePoint

1. Mount your SQL Server img.

2. Click on setup and Run as Administrator.

3. On SQL Server Installation Center page, click on Installation.

4. Click on SQL Server stand-alone installation or add feature to an existing installation

5. On SQL Server 2014 Setup page, Enter the product key or Specify a free edition.

Note: Evaluation will be expired in 180 days.

6. On License Terms page, checked I accept the license terms.

7. On Microsoft Update page, check the Use Microsoft Update to check for updates (recomended)

8. On Install Rules page, check the total passes, Failed, Warning and Skiped.

And correct accordingly.

9. If all passed click next.

10. On Setup Role page, choose SQL Server Feature Installation.

11. On Feature Selection select below features.

  • SQL Server Replication
  • Full-Text and Semantic Extraction for Search
  • Client Tools Connectivity
  • Integration Services
  • Documentation Component.
  • Client Tools Connectivity.
  • Management Tools-Basic and Click Next

Note: You can add features as per your requirement However Database Engine Services is only essential requirement for SharePoint Server. 

12. On Feature Rules page If you get Error

Microsoft .NET Framework 3.5 Service Pack 1 is required

Ok No worry Lets install Microsoft .NET Framework 3.5 Service Pack 1.

a. Click on Windows Server Manager Dashbord-->Manage--> On Add Roles and Feature Wizard page, Next-->Next-->Next-->Next-->.

b. On Features page checked .NET Framework 3.5 Features-->Next

c. On Confirmation installation selections page, Click Specify an alternate source path.

d. Copy your Windows Server 2012R2 in any drive and mount it. Click on source folder then sxs folder and copy the path.

e. Provide path to alternate access and click Install. .NET Framework 3.5 Features will install successfully. Close window.

13. Again start Installing SQL Server 2014.Repeat Steps 1 to 11.

14. Now you will get Instance Configuration Page, Either Change it or let it be Default instance and click Next.

15. On Server Configuration page, Check Account Name Password and Collation. I let it be Default. Will Change later

16. Add Current User or any user as Administrator in My case using Windows authentication Mode and current user is Administrator->Next

17. On Ready to Install page, review your Features and click Install.

18. On Installation progress page look at progress, take a while to install.

19. Check your Log.

 


by Amir Reza via Everyone's Blog Posts - SharePoint Community

Monday, March 7, 2016

Custom Image Slider in SharePoint

How to slide Image in SharePoint Page Using NIVO Slider Plugin, JQuery and SPServices.

I am going to use Script Editor built-in Web Part for this purpose.

1. Download NIVO Slider from here

2. Extract nivo slider zip file and add following file to your site assets or any other document library which you use to store libraries. I prefer site assets

   a. jquery.nivo.slider  (JS File)

  b. nivo-slider  (CSS File)

3. Navigate to themes in Extracted Folder. Find bar, dark, default, light folder.

Open each folder copy arrows, bullets and loading gif and add it to picture library or any other library which you use for keeping pictures.

(Remember you can’t keep more than one image with same name so will have to rename arrows, bullets and loading like arrowsbar , bulletsbar , loadingbar so on.. for each folder bar, dark, default, and light.)

Now open CSS of each folder bar, dark, default, and light find url and replace URL with respective gif url which you currently saved .

4. Add modified bar.css, dark.css, default.css and light.css to your site assets.

5. Add JQuery and SPServices  library to your site assets.

6. Create Document Library named it CompanyPicture.

7. Add some pics to CompanyPicture document library (I am using Demo picture from Nivo-Slider demo).

8.Add Script Editor Web Part to your page.

Gearbox-->Edit Page-->Insert-->Webart-->Media and Content-->Script Editor --> Add

9. Add reference of JQuery, SPServices, JQuery nivo slider, JQuery nivo,  nivo-slider css, bar.css, dark.css, default.css, light.css  which you have added in site assets to Script Editor Web Part.

10. Add below code to your Script Editor.

<link rel="stylesheet"  href="http:// your site name /SiteAssets/nivo-slider.css"/>

<link rel="stylesheet"  href="http:// your site name /SiteAssets/bar.css"/>

<link rel="stylesheet"  href="http://your site name/SiteAssets/default.css"/>

<link rel="stylesheet"  href="http://your site name/SiteAssets/dark.css"/>

<link rel="stylesheet"  href="http://your site name/SiteAssets/light.css"/>

 

<script src="http://your site name/SiteAssets/jquery-1.11.3.min.js"></script>

<script src="http://your site name/SiteAssets/jquery.nivo.slider.js"></script>

<script src="http://your site name/SiteAssets/jquery.SPServices-2013.js"></script>

<script type="text/javascript">

    $(document).ready(function() {

                                loadImage();

    });

                                                function loadImage(){

  $().SPServices({

        operation: "GetListItems",

        async: false,

        webURL: _spPageContextInfo.webAbsoluteUrl, // or any other site url where your CompanyPicture document library reside.

        listName: "CompanyPicture",

                                CAMLViewFields: "<ViewFields>"+

                     "<FieldRef Name=\'FileLeafRef\' />"+

                     "</ViewFields>",

completefunc: function (xData, Status) {

 $(xData.responseXML).SPFilterNode("z:row").each(function(){

       var FileLeafRef = $(this).attr("ows_FileLeafRef");

                   var splitdata = FileLeafRef.split("#");

                   var splitdataneed = splitdata[1];

       var addlist = "<a><img src=\"http://your site name/CompanyPicture/"+splitdataneed+"\" /></a>";                

        $("#slider").append(addlist);                

                   });

                   $('#slider').nivoSlider({

               effect: 'random',

               slices: 15,

               boxCols: 8,

               boxRows: 4,

               animSpeed: 500,

               pauseTime: 3000,

               startSlide: 0,

               directionNav: true,

               controlNav: true,

               controlNavThumbs: false,

               pauseOnHover: true,

               manualAdvance: false,

               prevText: 'Prev',

               nextText: 'Next',

               randomStart: false,

               beforeChange: function(){},

               afterChange: function(){},

               slideshowEnd: function(){},

               lastSlide: function(){},

               afterLoad: function(){}

});

            }

                   

 });

 }

  </script>

   <div id="wrapper">

     <div class="slider-wrapper theme-default">

       <div id="slider" class="nivoSlider">

                                   </div>

     </div>

  </div>

 Check your site.

 

Feedback is highly appreciated.

Thanks


by Amir Reza via Everyone's Blog Posts - SharePoint Community

Wednesday, February 24, 2016

How to Read/Import Excel Sheet in SharePoint List using SPServices and JQuery.

Recently I passed through an interesting requirement, had to import Excel sheet in SharePoint List.

Let’s Check how does it works.

For any demonstration I use my favorite web part Script Editor with lovely SPServices and JQuery

1. First Add a Custom List named it ExcelImport.

2. Create five Columns to the ExcelImport List.

First Name (Rename of Title Column), LastName, Position, Location, Country.

3. Now Next step is to add Script Editor Web Part to page.

4. Add Reference of SPServices and JQuery in Script Editor.

  (For frequent use I would suggest you to add reference in your master page)

5. Paste the below code in Script Editor.

<script src="Your JQuery Reference URL"></script>
<script src="Your SPServices Reference URL"></script>
<script>
var excel;
function GetData(cell,row){
if (window.ActiveXObject) {
try {
excel = new ActiveXObject("Excel.Application");
}
catch (e) {
alert (e.message);
}
}
else {
alert ("Opss... inconvenience caused is deeply regretted. Kindly Upload from IE");// Only work in IE Browser
return;
}

var excel_file = excel.Workbooks.Open("D:\MyExcelSheetName.xlsx");//Read excel from D drive by MyExcelSheetName Name
var sht = excel.Worksheets("Sheet1"); // Reading Sheet1 from Worksheets

for(var i=5; i<i+1; i++){ // will start reading data from 5th row
var FirstName = sht.Cells(i,3).Value; // Start reading First Name from 3rd cell
var LastName = sht.Cells(i,5).Value; // Start reading Last Name from 5th cell
var Position = sht.Cells(i,7).Value; // Start reading Position from 7th cell
var Location = sht.Cells(i,9).value; // Start reading Location from 9th cell
var Country = sht.Cells(i,11).Value; //Start reading Country from 11th cell

if (FirstName == undefined || LastName == undefined || Position == undefined || Location == undefined || Country == undefined){ // will stop reading data when excel data end.
break;
}
$().SPServices({
operation: "UpdateListItems",
webURL: _spPageContextInfo.webAbsoluteUrl,
async: false,
batchCmd: "New",
listName: "ExcelImport",
valuepairs: [["Title",FirstName],["LastName",LastName],["Position",Position],["Location",Location],["Country",Country]],
completefunc: function(xData,status){
}
});
}
alert("Data Imported");
excel_file.Close();

}

$(document).ready(function(){
$("#btnload").click(function(){
GetData(1,1);
});
});
</script>
<input type="button" style="float: left;" id="btnload" value="Import Excel"/>

6.Create your Excel file and save it to your D drive by  MyExcelSheetName.xlsx name.

Make sure your Excel Sheet must be in below format if you are using exactly above code.

7. Click on Import Excel button from your page. And your List will be updated with desired result.

Note : If you are getting Error like “Automation server can't create object

Enable Allow ActiveX filtering.

8. Verify your List.


Cheers ...

Thanks.


by Amir Reza via Everyone's Blog Posts - SharePoint Community

Monday, January 4, 2016

How to Uninstall/Remove SharePoint Workflow Manager 2013.

How to Uninstall/Remove SharePoint Workflow Manager 2013.

When SharePoint workflow manager 2013 install and configured it reflect at many places in the server.

To uninstall/Remove Workflow manager completely you will have to remove each component from the server which installed during configuration.

Let’s have look how to completely Uninstall/Remove workflow manager 2013.

First we need to remove Workflow Manager from the farm.

Leave the farm

Press windows + s in server where workflow manager is installed.

Type Workflow Manager Configuration

Open Workflow Manager Configuration

Click Leave workflow Manager Farm.

Click yes sign

Below programs will be removed

1. Remove current computer from the Workflow Manager farm

2. Remove current computer from the Service Bus farm

Uninstall prerequisite

During Installation as prerequisite following programs installed.

  1. Service Bus 1.1
  2. Windows Fabric
  3. Workflow Manager 1.0
  4. Workflow Manager Client 1.0

So these programs also need to uninstall.

Press windows + S and Type Programs and Features

Uninstalled all above four programs one by one.

Remove from Database

Apart from programs there are six databases created during installation.

SbGatewayDatabase.

SbManagementDB.

SBMessageContainer01.

WFInstanceManagementDB.

WFManagementDB.

WFResourceManagementDB.

Go to SQL Server Instance and Delete above Databases.

Now nothing left in your farm from workflow manager.

Cheers…..

Thanks .


by Amir Reza via Everyone's Blog Posts - SharePoint Community

How to configure workflow manager with SharePoint Server 2013.

When you start creating workflow with default Workflow Manager in SPD you will have only SharePoint 2010 Workflow in Platform Type.

To get SharePoint 2013 Workflow Platform Type need to install Workflow Manager 2013.

SharePoint Workflow Manager 2013 only supports SharePoint 2013 Standard and SharePoint 2013 Enterprise Edition not SharePoint foundation 2013.

In SharePoint 2013 developers have two Platform Type to create workflow.

  1. SharePoint 2010 Workflow -> Based on Windows Workflow Foundation 3. Installs automatically with SharePoint 2013 products.
  2. SharePoint 2013 Workflow -> Based on Windows Workflow Foundation 4 exclusively designed for use with SharePoint 2013. It don’t install automatically. Workflow Manager needs to download and install separately through Web Platform Installer.

Note: There is one more Platform Type SharePoint 2013 Workflow-Project Server but it requires Project Server 2013. I am not going in details.  

So this is little overview. Now let’s start configuring Workflow Manager 2013.

If you don’t have Microsoft Web Platform Installer 4.0 or Microsoft Web Platform Installer 5.0 already installed then install it.

  1. Search for Workflow Manager in Search Box in Web Platform Installer.
  2. Add Workflow Manager 1.0 Refresh (CU2).
  3. Click Install

Now Workflow Manager installed in your server. Next step is to configure it.

When you click on continue a configuration wizard will open.

  1. Click on Configure Workflow Manager with Defaults Setting (Recommended)

  1. Workflow Manager Configuration Wizard will open. Enter your SQL Server instance where you want to install your Workflow Manager Database and Test Connection.
  2. To Configure Service Account by default it gives you Windows Authentication to enter Configure Service Account. I am using Windows Authentication if you have to choose SQL server Authentication click on Advanced Options and select SQL Server Authentication.
  3. If you want to allow SharePoint Farm to communicate with Workflow Server over HTTP then checked Allow Workflow Management over HTTP on this Computer.

  1. In Certificate Generation Key enter your key keep in mind every time when you enter a computer to the farm you will have to supply same key. My case it is PassWord@1
  2. Click Next.  Here you will get Summery what’s going to happen in next phase.
  3. Click next. The entire perquisite will install one by one. Just keep calm and have hawk eyes on progress bar.  If everything done successfully click next.
  4.  Now you have successfully configured Workflow Manager 2013.

Next step is to register your WM.

This can be done only with PowerShell command.  

  1. Open your SharePoint PowerShell with Administrative Privilege.

Register-SPWorkflowService -SPSite ‘http://sitecollection’ -WorkflowHostUri ‘http://serverurl:12291’ –AllowOAuthHttp

 

sitecollection = your site collection URL it can be any site collection.

serverurl = This is your server url where you have installed  Workflow Manager recently. 12291 is port for Http and 12290 is Port for Https.

You can verify port with below PowerShell command.

Get-WFFarm | ft HttpPort
Get-WFFarm | ft HttpsPort

Note: If Workflow Manager is installed on a separate server which is not part of the SharePoint farm, you need to download and install the “Windows azure workflow manager client” on the each SharePoint server which you are configuring to use workflow and then run pairing cmdlet to register WM.

Now Check your workflow in SPD you have two platform type:

Cheers...

Thanks


by Amir Reza via Everyone's Blog Posts - SharePoint Community

Thursday, December 24, 2015

How to copy all data from ExcelSheet and Paste in SharePoint List.

How to copy all data from ExcelSheet and Paste in SharePoint List.

Create Custom List CustomerDetails3 in SharePoint with four fields (CustomerID,CustomerName,Location,MobNumber)

1. Copy your data from excel sheet (only data no headers)

2. Open CustomerDetails3 List in IE (Chrome don’t support)

3. Click edit

4. Bring cursor at CustomerID with keyUP/KeyDown (don’t use mouse)

5.Press Ctrl+V

6.Stop editing.

Verify data

Done  cheers 


by Amir Reza via Everyone's Blog Posts - SharePoint Community

Wednesday, December 23, 2015

CRUD Operation Using REST API in SharePoint List with script editor Web Part.

CRUD Operation Using REST API in SharePoint List with script editor.

The goal of this blog is to perform CRUD operation in SharePoint List using REST API In Script Editor Web Part.

Steps.

Create Custom List in SharePoint.

Created one Custom List named Customer with five Fields (Customer ID, First Name, Last Name, Location, Ph-Number) as below.

JQuery Library.

Have to use JQuery with REST API. So to include JQuery reference download JQuery library from here and upload to site Assets.

Script Editor.

Script Editor is web part provided in SharePoint 2013 for page level scripting.

How to add Script Editor Web Part.

GearBox-> Edit Page -> INSERT - > WebPart -> (In Categories) Media and Content -> (In Parts) -> Script Editor-> Add

Now Click Edit Snippet in Script Editor and start codding.

First add JQuery reference to Script Editor from Site Assests JQuery Library.

Copy URL and paste in scr.

<script src=”http://<site>/SiteAssets/jquery-1.11.3.min.js”></script>

Next step is to perform CRUD operation on Customer List.

Copy and Paste below code in Script Editor.

//Replace with your JQuery url

<script src="http://<your site name>/SiteAssets/jquery-1.11.3.min.js"></script>

<script>

var v1, v2, v3, v4, v5, itemid;

$(document).ready(function(){

 createItem();

 read();

 update();

 Deleted();

});

function read(){

var resturl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Customer')/items";

$.ajax({

url:  resturl,

        method: "GET",

        headers: { "Accept": "application/json; odata=verbose" },

        success: function (data) {

            var lnt = data.d.results.length;

             for(var i=0; i<lnt; i++ ){

              var title = data.d.results[i].Title;

              var firstname = data.d.results[i].First_x0020_Name;

              var lastname = data.d.results[i].Last_x0020_Name;

              var phnumber = data.d.results[i].Ph_x002d_Number;

               var location = data.d.results[i].Location;

                      var id = data.d.results[i].ID;

           var tbldata = "<tr><td><input type='radio' class='addcls' name='rd1'  value='"+id+"' onclick='javascript:getcheked();' /></td><td >"+title+"</td><td>"+firstname+"</td><td>"+lastname+"</td><td>"+location+"</td><td>"+phnumber+"</td></tr>"

               $("#tbl2").append(tbldata);

}

        },

        error: function (data) {

           console.log(data.responseJSON.error);

        }

});

}

function addNewItem(url, data) {

    $.ajax({

        url: _spPageContextInfo.webAbsoluteUrl + url,

          type: "POST",

          headers: {

         "accept": "application/json;odata=verbose",

         "X-RequestDigest": $("#__REQUESTDIGEST").val(),

         "content-Type": "application/json;odata=verbose"

        },

        data: JSON.stringify(data),

        success: function (data) {

            alert("Record Added");

        },

        error: function (error) {

           console.log(JSON.stringify(error));

        }

    });

}

function GetItemTypeForListName(name) {

 return"SP.Data." + name.charAt(0).toUpperCase() + name.slice(1) + "ListItem";

}

function createItem(){

$("#btn-add").click(function(){

var addNewItemUrl = "/_api/Lists/GetByTitle('Customer')/Items";

var itemType = GetItemTypeForListName('Customer');

var CustomerId = $("#CustomerId").val();

var CustomerFirstName = $("#CustomerFirstName").val();

var CustomerLastName = $("#CustomerLastName").val();

var CustomerLocation = $("#CustomerLocation").val();

var CustomerPhNumber = $("#CustomerPhNumber").val();

 var item = {

        "__metadata": { "type":  itemType },

        "Title": CustomerId,

         "First_x0020_Name": CustomerFirstName,

         "Last_x0020_Name": CustomerLastName,

          "Location": CustomerLocation,

          "Ph_x002d_Number": CustomerPhNumber

    };

 addNewItem(addNewItemUrl, item);

});

}

function update(){

$("#btndel").click(function(){

var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Customer')/getItemById(" + itemid + ")";

var itemType = GetItemTypeForListName('Customer');

var item = {

        "__metadata": { "type": itemType },

        "Title": v1,

         "First_x0020_Name": v2,

         "Last_x0020_Name": v3,

         "Location": v4,

         "Ph_x002d_Number": v5

    };

 

UpdateData(requestUri,item);

});

}

function getcheked(){

$(".addcls").each(function(){

        if($(this).is(":checked")){

                       var chkdata = $(this).val();

                                                 $("#hdndata").val(chkdata);

                                                 itemid =$("#hdndata").val();

                                                 var $row = $(this).closest("tr"),        // Finds the closest row <tr>

                         $tds2 =  $row.find("td:nth-child(2)");

                         $tds2.prop("contentEditable", "true");

                         $tds2.keyup(function(){

                             v1 = $(this).text();

                          });

                          $tds3 = $row.find("td:nth-child(3)")

                        $tds3.prop("contentEditable", "true");

                         $tds3.keyup(function(){

                         v2 = $(this).text();

                          });

                           $tds4 = $row.find("td:nth-child(4)");

                         $tds4.prop("contentEditable", "true");

                         $tds4.keyup(function(){

                             v3 = $(this).text();

                          });

                          $tds5 = $row.find("td:nth-child(5)");

                          $tds5.prop("contentEditable", "true");

                         $tds5.keyup(function(){

                             v4 = $(this).text();

                          });

                          $tds6 = $row.find("td:nth-child(6)");

                          $tds6.prop("contentEditable", "true");

                         $tds6.keyup(function(){

                             v5 = $(this).text();

                          });

                                                         }

   })

}

function UpdateData(requestUri,item){

$.ajax({

url: requestUri,

type: "POST",

data:JSON.stringify(item),

headers: {

"accept":"application/json;odata=verbose",

"content-type": "application/json;odata=verbose",

 "X-RequestDigest": $("#__REQUESTDIGEST").val(),

"X-HTTP-Method": "MERGE",

"IF-MATCH":"*"

},

success: onSuccess,     

error: onError 

});

}

function onSuccess(data) {

 alert("Updated");

}

 function onError(error) {

console.log(JSON.stringify(error));

}

 

function DeleteItem(deleteuri){

$.ajax({

url: deleteuri,

type: "POST",

headers: {

"accept":"application/json;odata=verbose",

"content-type": "application/json;odata=verbose",

 "X-RequestDigest": $("#__REQUESTDIGEST").val(),

"X-HTTP-Method": "DELETE",

"IF-MATCH":"*"

},

success: onDeleteSuccess,

error: onDeleteError

});

}

 function onDeleteSuccess(){

alert("Entry Deleted");

}

 function onDeleteError(){

console.log(JSON.stringify(error));

}

function Deleted(){

$("#btndelete").click(function(){

var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Customer')/getItemById(" + itemid + ")";

DeleteItem(requestUri);

});

}

 </script>

<div id="createData"> 

    <table> 

        <tr> 

            <td> 

                <table> 

                    <tr> 

                        <td>Customer Id</td> 

                        <td>

                            <input type="text" id="CustomerId"/> 

                        </td> 

                    </tr> 

                    <tr> 

                        <td>First Name</td> 

                        <td> 

                            <input type="text" id="CustomerFirstName"/> 

                        </td> 

                    </tr> 

                    

                    <tr> 

                        <td>Last Name</td> 

                        <td> 

                            <input type="text" id="CustomerLastName"/> 

                        </td> 

                    </tr> 

                    <tr> 

                        <td>Location</td> 

                        <td> 

                            <input type="text" id="CustomerLocation" /> 

                        </td> 

                    </tr> 

                    <tr> 

                        <td>Ph-Number</td> 

                        <td> 

                            <input type="text" id="CustomerPhNumber"/> 

                        </td> 

                    </tr> 

                    <tr> 

                        <td> 

                            <button value="Add" id="btn-add">Add</button> 

                        </td> 

                    </tr> 

                </table> 

            </td> 

        </tr> 

    </table> 

</div> 

<div id="readData">

<div id="tbldatamain">

<table id=tbl2>

<tr><th><input type="radio"></th></input><th>Customer ID</th><th>First Name</th><th>Last Name</th><th>Location</th><th>Ph-Number</th></tr>

</table>

</div>

<input type="hidden" id="hdndata" value=""/>

<div>

<table><tr><td><button id="btndel">Update</button></td><td><button id="btndelete">Delete</button></td></tr>

</div>

</div>

<style>

#readData{

position: absolute;

top: 205px;

left: 915px;

}

</style>

After pasting code Click Insert->Check In -> Publish this draft

And visit to page. Page will look like below

To Add -> Fill data and click add.

To Update -> Checked Radio button. After checked Data field will become editable. Edit field and click update.

To Delete ->  Checked Radio button and click Delete.

 

 

 

 

 


by Amir Reza via Everyone's Blog Posts - SharePoint Community