+91-90427 10472
         
Dot net training in Chennai

CRUD operation in share point using JSOM

Document by Ganesanva@hotmail.com – + 919042710472

This blogs shows you an example for JavaScript Client side object model.
Create a List “EmployeeList” with below columns,

The List looks like below,

Create a text file “Saveitem.txt” and js file “Saveform.js” in Site Assets as shown below,

Put the below code in Saveitem.txt,

<script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>
<script type=”text/javascript” src=”/SiteAssets/Saveform.js”>
</script>
<table border=”0″ cellspacing=”2″ cellpadding=”2″>
<tr>
<td>
Employee Name
</td>
<td>
<input type=”text” id=”txtEmpName” />
</td>
</tr>
<tr>
<td>
Employee Age
</td>
<td>
<input type=”text” id=”txtEmpAge” />
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type=”hidden” id=”txtId” />
<input type=”Button” value=”Save” id=”btnSave” onclick=”createItem()” />
<input type=”Button” value=”Update” id=”btnUpdate” onclick=”updateItem()” />
</td>
</tr>
<tr>
<td colspan=”2″>
<table border=”0″ cellspacing=”2″ cellpadding=”2″ id=”tbldata”>
<thead>
<tr>
<td>
Id
</td>
<td>
Employee Name
</td>
<td>
Employee Age
</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
</td>
</tr>
</table>

Put the below code in “Saveform.js”,

$(document).ready(function(){
$(‘#btnUpdate’).hide();
SP.SOD.executeFunc(‘sp.js’, ‘sp.runtime’, retrieveListItems);
});
function editvalue(element)
{
var Id=element.parentNode.parentElement.cells[0].outerText;
var EmpName=element.parentNode.parentElement.cells[1].outerText;
var Age=element.parentNode.parentElement.cells[2].outerText;
$(‘#txtId’).val(Id);
$(‘#txtEmpName’).val(EmpName);
$(‘#txtEmpAge’).val(Age);
$(‘#btnUpdate’).show();
$(‘#btnSave’).hide();
}
function updateItem() {
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle(‘EmployeeList’);
var listItem = list.getItemById($(‘#txtId’).val());
listItem.set_item(“Title”, $(‘#txtEmpName’).val());
listItem.set_item(“EmployeeName”, $(‘#txtEmpName’).val());
listItem.set_item(“Age”, $(‘#txtEmpAge’).val());
listItem.update(); //Update the List Item
context.load(listItem);
context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail);
}
function createItem() {
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle(‘EmployeeList’);
var listCreationInformation = new SP.ListItemCreationInformation(); //Object for creating Item in the List
var listItem = list.addItem(listCreationInformation);
listItem.set_item(“Title”, $(‘#txtEmpName’).val());
listItem.set_item(“EmployeeName”, $(‘#txtEmpName’).val());
listItem.set_item(“Age”, $(‘#txtEmpAge’).val());
listItem.update(); //Update the List Item
context.load(listItem);
context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail);
}
function onGetUserNameSuccess() {
$(‘#txtEmpName’).val(”);
$(‘#txtEmpAge’).val(”);
$(‘#btnUpdate’).hide();
$(‘#btnSave’).show();
alert(‘Success’);
retrieveListItems();
}
// This function is executed if the above call fails
function onGetUserNameFail(sender, args) {
alert(‘Failed to get user name. Error:’ + args.get_message());
}
var siteUrl = ‘http://htc:7004/‘;
function retrieveListItems() {
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle(‘EmployeeList’);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(‘<View><Query></Query></View>’);
this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded(sender, args) {
var listItemEnumerator = collListItem.getEnumerator();
$(‘#tbldata tbody’).empty();
while (listItemEnumerator.moveNext())
{
var oListItem = listItemEnumerator.get_current();
$(‘#tbldata tbody’).append(‘<tr class=”child”><td>’+oListItem.get_item(‘ID’) +'</td><td>’+oListItem.get_item(‘Title’) +'</td><td>’+oListItem.get_item(‘Age’) +'</td>’+'<td>’+
‘<input type=\”Button\” value=\”Edit\” onclick=\”editvalue(this)\” /></td></tr>’);
}
}
function onQueryFailed(sender, args) {
alert(‘Request failed. ‘ + args.get_message() + ‘\n’ + args.get_stackTrace());
}

Create a page in Site pages library and edit the page,


Put “/SiteAssets/Saveitem.txt” in Content Editor web part.
Output as below,

Click on Save.
Click on Edit.

Click Update.

Click here to download the solution,
https://1drv.ms/u/s!ArddhCoxftkQg9VWsy-V87mHMy6C1g

Create External List using BCS in share point 2010

Open Central Administration in SharePoint.
Go to Application Management -> Manage Service Applications as shown below.

Click on New ->Business Data Connectivity Service

Enter Service Application Name and Click OK.

Business Data Connectivity Service application is created as shown below,

Create New -> Secure Store Service application as shown below,

Enter the name “Secure Store Service” and Click Ok.

Secure Store service is created as shown below.

Business Connectivity service and Secure store service are the prerequisites for Creating BCS in SharePoint.
Open site in SharePoint Designer as shown below.

Open Sql Server and Create a Database StudentDB.
Create a Table EmployeeDB with below Script,

CREATE TABLE [dbo].[EmployeeDB](
[EmployeeID] [int] IDENTITY(1,1) NOT NULL,
[EmployeedName] [text] NULL,
[EmployeedSalary] [float] NULL,
CONSTRAINT [PK_EmployeeDB] PRIMARY KEY CLUSTERED
(
[EmployeeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

Table Design looks as below,

Go to External Content types option in SPD as shown below,

Click on External Content Type button in Top menu. The designer looks as below,

Click on the option “Click here to discover external data sources and define operations” under External Content Type Operations.
The designer looks as below,

Click on Add Connection.


Click OK.

Right Click on the Table and Select Create all operations as shown below.


Click on Next.

Click on Finish.
Save the Content Type in the Name EmployeeDB as shown below.

Open the SharePoint Site http://htc:7004/ in Browser.
Click on Site Action -> Site Content.
Click on Create.

Click on External List.

Click Create.
Select the Content type from the list.

Click Ok.

Give name as Employee Table and Click on Create.
The Output as below,
External List is created as shown below.



Now the External List allow CRUD Operation.

Dot net / SharePoint freelance Consultants in Chennai

Document by Ganesan – Ganesanva@hotmail.com – +919042710472

Given the huge demand for dot net and SharePoint applications today and the growing importance of freelancers across the city, .net and SharePoint freelancers in Chennai have engaged in providing the best available professional coaching in the software applications. The job opportunities for dot net with certification have significantly increased the number of .net freelancers in Chennai. Whether it is for professional or educational purposes, it is advisable to take a Dot net Freelance trainer in Chennai to meet the ever-changing demands of corporates and educational systems.

Hiring a Microsoft certified trainer in Chennai helps with professional coaching on Microsoft technologies such Asp.Net, C#.Net, SQL server etc. And in today’s digitalized world, the virtual presence of the trainers in substantial enough for an expert coaching on the applications. An online Dot net trainer uses the best practices of the industry to ensure dot net and SharePoint solutions meet business and educational needs of contemporary period.
A certified Dot net corporate trainer in Chennai combines the passion for technological innovation and deep platform expertise to ensure that proper training is delivered. The key focus of an online Dot net trainer in Chennai is to equip individuals leverage dot net and SharePoint technologies effectively to meet the professional and educational requirements. Young and dynamic professional and aspiring students can utilize the services of many Dot net part time consultants in Chennai to handle challenging and innovative projects. Further, given the array of opportunities in SharePoint and dot net, career as a Freelance SharePoint developer in Chennai or as an asp.net MVC consultant in Chennai holds a lot of promise for the future.

Today’s competitive market has brought dot net and SharePoint professionals to the forefront. A few years ago, a dot net or a SharePoint consultant in Chennai would have been just another consultant but today dot net and SharePoint developers have defined the career path of many individuals and professional services. Being ahead of the industry and constantly upgrading in the latest versions, dot net and SharePoint developers have been and are the preferred vendors for many corporates and students for their training and educational needs.

Along with a good demonstration of how projects are developed in real-time environment, a Microsoft certified trainer in Chennai imparts confidence and knowledge of technical skills for both freshers and working professionals and also ensures that the sessions are well structured and interactive.

With the shifting expectations of the IT industry and education, the ecosystems of dot net and SharePoint and the range of professionalism exhibited by dot net and SharePoint trainers have become more radical and created excitement and interest in learning more about the applications.