Wednesday 13 December 2017

CRUD Operation in sharepoint using AngularJS

HTML PART

<link type="text/css" rel="stylesheet" href="/SiteAssets/bootstrap.min.css">
<script type="text/javascript" src="/SiteAssets/jquery.min.js"></script>
<script type="text/javascript" src="/SiteAssets/bootstrap.min.js"></script>
<script type="text/javascript" src="/SiteAssets/angular.js"></script>
<script type="text/javascript" src="/SiteAssets/SPCRUD.js"></script>
   
    <div ng-app="spApp" style="width:50%">
    <h3>View Employee Detail</h3>
    <hr />
        <div ng-controller="viewItemsController">
        <table>
        <thead>
        <tr>
        <th>S.No</th>
        <th>Name</th>
        <th>Age</th>
        <th>Gender</th>
        <th>Salary</th>
        </tr>
        </thead>
        <tbody>
        <tr ng-repeat="employee in employees">
        <td>{{employee.ID}}</td>
        <td>{{employee.Name}}</td>
        <td>{{employee.Age}}</td>
        <td>{{employee.Gender}}</td>
        <td>{{employee.Salary}}</td>
        </tr>
        </tbody>
        </table>
        </div>
        <hr />

        <h3>Add Employees</h3>
        <div ng-controller="addItemsController">
            <div class="form-horizontal">
                <div class="form-group">
                    <label class="control-label col-sm-5" for="Ename">Employee Name :</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" id="Ename" ng-model="name" >
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-5" for="Eage">Age :</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" id="Eage" ng-model="age" >
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-5" for="Egen">Gender :</label>
                    <div class="col-sm-7">
                    <label><input  type="radio" id="Emale" name="Egen" ng-model="gender" ng-value="'Male'">Male</label>
                        <label><input  type="radio" id="EFemale" name="Egen" ng-model="gender" ng-value="'Female'">Female</label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-5" for="Esal">Salary :</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" id="Esal" ng-model="salary">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-5">
                       
                    </div>
                    <div class="col-sm-3">
                        <input type="button" class="btn btn-default form-control" id="btnAddEmployee" value="Add Employee" ng-click="addEmployee()">
                    </div>
                </div>
            </div>
        </div>
        <hr/>


        <h3>Edit Employees</h3>
        <div ng-controller="editItemsController">
        <div class="form-horizontal">
        <div class="form-group">
                    <label class="control-label col-sm-5" for="itemId">ID :</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" id="itemId" ng-model="itemId">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-5" for="Ename">Employee Name :</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" id="Ename" ng-model="name" >
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-5" for="Eage">Age :</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" id="Eage" ng-model="age" >
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-5" for="Egen">Gender :</label>
                    <div class="col-sm-7">
                    <label><input  type="radio" id="Emale" name="Egen" ng-model="gender" ng-value="'Male'">Male</label>
                        <label><input  type="radio" id="EFemale" name="Egen" ng-model="gender" ng-value="'Female'">Female</label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-5" for="Esal">Salary :</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" id="Esal" ng-model="salary">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-5">
                       
                    </div>
                    <div class="col-sm-3">
                        <input type="button" class="btn btn-default form-control" id="btnEditEmployee" value="Edit Employee" ng-click="editEmployee()">
                    </div>
                </div>
            </div>
        </div>
        <hr/>


        <h3>Delete Employees</h3>
        <div ng-controller="delItemsController">
            <div class="form-horizontal">
                <div class="form-group">
                    <label class="control-label col-sm-5" for="itemId">ID :</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" id="itemId" ng-model="itemId">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-5">
                       
                    </div>
                    <div class="col-sm-3">
                        <input type="button" class="btn btn-default form-control" id="btnDelEmployee" value="Delete Employee" ng-click="delEmployee()">
                    </div>
                </div>
            </div>
        </div>
    </div>
   
Angular JS Part

/// <reference path="/SiteAssets/angular.js" />

var listName = "AngularCRUD";
var spApp = angular
                .module("spApp", [])
                .controller("viewItemsController", function ($scope, $http,$log) {
                debugger;
                    var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('"+ listName +"')/items?$select=Name,Age,Gender,Salary,ID";
                    $http(
                    {
                        method: "GET",
                        url: url,
                        headers: { "accept": "application/json;odata=verbose" }
                    }
                    ).then(function (response, status, headers, config) {
                        $scope.employees = response.data.d.results;
                        $log.info(response);
                    },function (reason, status, headers, config) {
                    
                    });                    
                })

                .controller("addItemsController", function ($scope, $http) {
                    var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('"+ listName +"')/items";
                    var vm = $scope;
                    vm.addEmployee = function () {
                    debugger;
                        return $http({
                            headers: { "Accept": "application/json; odata=verbose", "X-RequestDigest": jQuery("#__REQUESTDIGEST").val() },
                            method: "POST",
                            url: url,
                            data: {
                                'Name': vm.name,
                                'Age': vm.age,
                                'Gender': vm.gender,
                                'Salary': vm.salary
                            }
                        })
                        .then(saveEmployee)
                        .catch(function (message) {
                            console.log("addEmployee() error: " + message);
                        });
                        function saveEmployee(data, status, headers, config) {
                            alert("Item Added Successfully");
                            vm.name = "";
                            vm.age = "";
                            vm.gender = "";
                            vm.salary = "";
                        }
                    }
                })

                .controller("editItemsController", function ($scope, $http) {
                    debugger;
                    var vm = $scope;                    
                    vm.editEmployee = function () {
                     debugger;
                        var data = {
                            '__metadata': {
                                'type': 'SP.Data.'+ listName +'ListItem'
                            },
                            'Name': vm.name,
                            'Age': vm.age,
                            'Gender': vm.gender,
                            'Salary': vm.salary
                        };
                        return $http({
                            headers: {
                                "Accept": "application/json; odata=verbose",
                                "Content-Type": "application/json; odata=verbose",
                                "X-HTTP-Method": "MERGE",
                                "X-RequestDigest": document.getElementById("__REQUESTDIGEST").value,
                                "Content-Length": data.length,
                                'IF-MATCH': "*"
                            },
                            method: "POST",
                            url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('"+ listName +"')/items(" + vm.itemId + ")",
                            data: data
                        })
                        .then(saveEmployee)
                        .catch(function (message) {
                            console.log("editEmployee() error: " + message);
                        });
                        function saveEmployee(data, status, headers, config) {
                            alert("Item Edited Successfully");
                            return data.data.d;
                        }
                    }
                })

                .controller("delItemsController", function ($scope, $http) {
                    
                    var vm = $scope;                    

                    vm.delEmployee = function () {
                        return $http({
                            headers: {
                                "X-HTTP-Method": "DELETE",
                                "X-RequestDigest": document.getElementById("__REQUESTDIGEST").value,
                                'IF-MATCH': "*"
                            },
                            method: "POST",
                            url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('"+ listName +"')/items(" + vm.itemId + ")"
                        })
                        .then(saveEmployee)
                        .catch(function (message) {
                            console.log("delEmployee() error: " + message);
                        });
                        function saveEmployee(data, status, headers, config) {
                            alert("Item Deleted Successfully");
                            return data.data.d;
                        }
                    }
                });

                


Monday 11 December 2017

Format code shortcut for Visual Studio?

To answer the specific question, in C# you are likely to be using the C# keyboard mapping scheme, which will use these hotkeys by default:
Ctrl+ECtrl+D to format the entire document.
Ctrl+ECtrl+F to format the selection.
You can change these in Tools > Options > Environment -> Keyboard (either by selecting a different "keyboard mapping scheme", or binding individual keys to the commands "Edit.FormatDocument" and "Edit.FormatSelection").
If you have not chosen to use the C# keyboard mapping scheme, then you may find the key shortcuts are different. For example, if you are not using the C# bindings, the keys are likely to be:
Ctrl + K + D (Entire document)
Ctrl + K + F (Selection only)
To find out which key bindings apply in YOUR copy of Visual Studio, look in the Edit > Advanced menu - the keys are displayed to the right of the menu items, so it's easy to discover what they are on your system.

For various sharepoint doubts
Please refer:  http://sharepoint112.blogspot.in/

Access Modifiers And Default Access Modifiers In C#

We have the following access modifiers available in C#.
  • Public
  • Private
  • Protected
  • Internal
  • Protected Internal
How to choose the appropriate access modifiers in our application is a big hurdle. Let’s try to find out the solution through few of the small implementations.
Level of Implementation/Access modifiers typesAt Namespace levelAt class Level At function level
Publicyesyes
PrivateNoyes
ProtectedNoyes
Internalyesyes
Protected InternalNoyes
I have tried to create a tabular view for simplification. Now, let’s try to explore what the table data shows.

The table column header shows where the implementation can be possible; i.e., at which level we are eligible to access which types of access modifiers.

Note: At function level everything is private; we cannot even explicitly declare private to a data member.

Implementation at Namespace level
Any element which can be defined atthe namespace level should have either public or internal access modifiers. Let’s prove the same.

error

Here we have tried to define a class of accessibility level as privateInterface with accessibility level as protectedenum with accessibility level as protected internal and a structure.

At the bottom of the screen we can clearly see the Error saying Error “Elements defined in a namespace cannot be explicitly declared as private, protected, or protected internal"
It means we are only left with the option of public or internal. Now how do we identify what is the default access modifiers for elements at namespace level? Friends, it is a very interesting and tricky interview question. I have been bombarded with the question, "What is the default access modifier in C#?" in many of the interviews I have appeared in as an interviewee. 

I always thought it to be “internal,” however, I realized my conception was wrong when I tried to figure it out on my own. I understand when the question arises, what is the default access modifier in c#, we should ask the interviewer whether they want to know about the elements at namespace level or about the elements at class/function levels.

To get into the appropriate answer of this question, let refer few of the definition that MSDN site suggests.
 Within NamespaceOutside Namespace
PublicAccess is not restricted.Accessible outside namespace.
PrivateAccess is limited to containing type.Not accessible outside the namespace.
ProtectedAccess is limited to the containing class or types derived from the containing class. 
InternalAccess is limited to current assembly only.Not accessible.
Protected InternalAccess is limited to the current assembly or types derived from the containing class.Outside the namespace, only accessible to the types derived from the containing class.
So far we have concluded that any element in namespace level is either public or internal. However, we have not yet reached any concrete statement yet. 

However, let’s see outside “CheckAccessModifiers” assembly if we are able to access the Namespace level elements. 

Steps:
  1. We have created two classes named MyCustomClass and MyCustomClass1 in namespace “CheckAccessModifiers”.
  2. Build the project. Create one more console project (in our example it is OutSideAssembly) at solution level.
  3. Add a reference of “OutSideAssembly” to “CheckAccessModifiers”.
  4. Include the namespace (using CheckAccessModifier)
  5. In Main () method try to access the elements of “CheckAccessModifiers” Namespace.
CheckAccessModifiers

Let’s see the below example. Here we have created another class named MyCustomClass1 and tried to access the members of MyCustomClass.

MyCustomClass1

We are only able to see “MyCustomClass1”. 

Findings
The reference table from MSDN says, internal is only accessible in current assembly. Public modifiers can be accessed anywhere. If we recall it properly in our very first example, we saw elements at Namespace level can either be public or internal.

We had two classes named MyCustomClass and MyCustomClass1. The type of access modifiers they hold is unknown/default and public. Since at name space level we cannot use private/protected internal/protected. 

MyCustomClass1 is accessible in namespace “OutSideAssembly” since it is declared as public, which means the default access modifier in C# at Namespace level element is “Internal”.

Implementation at Class Level and Function Level
To understand this concept, we have created three classes withinthe namespace “CheckAccessModifiers.” Currently, MyCustomClass is holding some data members of different access levels. MyCustomClass2 is inheriting from MyCustomClass.

We end up with two scenarios again. First we will check the behavior of the data members available in MyCustomClass within same namespace but inside different classes.

Scenario 1: (Within Namespace, outside class- In our case it is MyCustomClass1)

Within Namespace

After creating the object, we can see only fifthNumber, firstNumber and fouthNumber is available to us.

I.e. only members having modifiers either public/protected internal/internal is accessible in other classes. 

Scenario 2: (Within Namespace, outside class inheriting from base class- in our case it is MyCustomClass2).

We are again having access to fifth, first, fourth and third variable. I.e. only members having modifiers either public/protected internal/internal/Protected is accessible in other classes. 

accessible in other classes

Now we end up with a question, if public/protected internal/internal is available anywhere in the namespace how do we choose the appropriate access modifier at class level?

Let’s check the behavior outside the Namespace. We will follow to same steps and go to Namespace “OutSideAssembly”.

Below is the structure of classes in “OutSideAssembly” Assembly.

structure of classes 

We have two more classes named Program and MyCustomClass3. MyCustomClass3 is inheriting from MyCustomClass. Our intention is to check the availability of data members outside the namespace.

Inside program class, when we try to access the following, is output.

output

Only firstNumber variable is available. This justifies the definition that public members have no restriction at all. 

Let’s see the behavior inside MyCustomClass3.

MyCustomClass3

We are able to access first, fifth, and third variable.

On derived class examples whether it is within the namespace or outside the namespace, we saw that members with accessibility protected and protected internal is available in derived class.

Then how to choose when to Choose Protected and when to choose protected internal?

Solution
Friends this part is bit interesting, when we want any member to be available only in derived class within the same assembly but not to a normal class in other assembly, then one should go with Protected; however, if one is looking for a member which will be available anywhere in the current assembly but only in derived class in the outside namespace then one should choose protected internal.

Conclusion
Default access modifiers at Namespace level are internal.

Default access modifiers at Class level are private.

Default access modifiers at function level are private; we are not allowed to use even private keywords explicitly.

How to Create your own run commands?

There is a simple and easy way to create your own run command..

1. Open C:\Windows.
2. Create a shortcut of the app you want to create run command into that folder.
3. Rename that app as your wish(without space).
4. Open Run box(win + R) and type that name it will open that app.



Wednesday 29 November 2017

Get choice from list

function GetDropDown(success,failure)
 {
 debugger;
     $.ajax({
        url: siteURL + "/_api/web/lists/getbytitle('listname')/fields?$filter=EntityPropertyName eq 'column1' or EntityPropertyName eq 'column2' or EntityPropertyName eq 'column3'",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data) {
           //success(data.d.results);
            success(data.d.results);   
        },       
        error: function (data) {
        debugger;
            failure(data);
           
        }
        });
 }
/* Function to getting all dropdown items from library success*/
function DropDownvaluessuccess(Dropdownarray)
{
    debugger;   
     if(Dropdownarray.length>0)
     {
        var cln1dd='<option selected value="Select">Select</option>';
        var cln2dd='<option selected value="Select">Select</option>';
        var cln3dd='<option selected value="Select">Select</option>';
           
            var cln1=Dropdownarray[0].Choices.results;
            var cln2=Dropdownarray[1].Choices.results;
            var cln3=Dropdownarray[2].Choices.results;
           
            for(var i=0;i<cln1.length;i++)
            {             
                cln1dd+='<option value='+i+'>'+cln1[i]+'</option>';
            }
            for(var i=0;i<cln2.length;i++)
            {             
                cln2dd+='<option value='+i+'>'+cln2[i]+'</option>';             
            }
            for(var i=0;i<cln3.length;i++)
            {
                cln3dd+='<option value='+i+'>'+cln3[i]+'</option>';
            }
           
            $("#TaxType").empty().append(cln1dd);
            $("#cln2").empty().append(cln2dd);
            $("#TaxCountry").empty().append(cln3dd);
                   
     }     
}
/* Function to getting all dropdown items from library on failure*/
function DropDownvaluesfailure()
{
    debugger;
}

creating a csv dynamically

function WriteToFile() {
debugger;
      var data0 = [
        ["A","B","C","D"],
        ["a","b","c","d"]
      ];
      var docTitle = "SupplierBusinessClassification.csv";   
        download_csv(data0,docTitle)           
}

function download_csv(data,docName) {
    var csv;
    data.forEach(function(row) {
        csv += row.join(',');
        csv += "\n";
    });

    console.log(csv);
    var hiddenElement = document.createElement('a');
    hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);
    hiddenElement.target = '_parent';
    hiddenElement.download = docName;
    hiddenElement.click();
}

Multiple Attachment into list

<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.js"></script>
<input type="text" id="Title">
<input type="textarea" id="Body">
<input type="file" id="file_input">
<script type="text\javascript">
var vendorList = "list name";

function CreateVendor() {

var data = []; 
var fileArray = [];   
fileArray.push({ "Attachment": $('#file_input')[0].files[0]})
fileArray.push({ "Attachment": $('#file_input')[0].files[1]})
fileArray.push({ "Attachment": $('#file_input')[0].files[2]})

createNewItemWithAttachments(vendorList, fileArray).then( 
function () {                         
}, 
function (sender, args) { 
console.log('Error occured' + args.get_message()); 

)   
}

 var createNewItemWithAttachments = function (vendorList, fileArray) {
    debugger;
        var fileCountCheck = 0; 
        var fileNames; 
        var context = new SP.ClientContext.get_current(); 
        var dfd = $.Deferred(); 
        var targetList = context.get_web().get_lists().getByTitle(vendorList); 
        context.load(targetList); 
        var itemCreateInfo = new SP.ListItemCreationInformation(); 
        var listItem = targetList.addItem(itemCreateInfo); 
        listItem.set_item('Title', $("#Title").val());
listItem.set_item('Body', $("#Body").val());
        listItem.update(); 
        context.executeQueryAsync( 
            function () {
            debugger;
                var id = listItem.get_id(); 
                if (fileArray.length != 0) { 
                    if (fileCountCheck <= fileArray.length - 1) { 
                        loopFileUpload(vendorList, id, fileArray, fileCountCheck).then( 
                            function () { 
                            }, 
                            function (sender, args) { 
                                console.log("Error uploading"); 
                                dfd.reject(sender, args); 
                            } 
                        ); 
                    } 
                } 
                else { 
                    dfd.resolve(fileCountCheck); 
                } 
            }, 
            function (sender, args) { 
            debugger;
                console.log('Error occured' + args.get_message()); 
            } 
        ); 
        return dfd.promise(); 
    } 
 
    function loopFileUpload(vendorList, id, fileArray, fileCountCheck) {
    debugger; 
        var dfd = $.Deferred(); 
        uploadFileHolder(vendorList, id, fileArray[fileCountCheck].Attachment).then( 
            function (data) { 
                var objcontext = new SP.ClientContext(); 
                var targetList = objcontext.get_web().get_lists().getByTitle(vendorList); 
                var listItem = targetList.getItemById(id); 
                objcontext.load(listItem); 
                objcontext.executeQueryAsync(function () { 
                    console.log("Reload List Item- Success"); 
                    fileCountCheck++; 
                    if (fileCountCheck <= fileArray.length - 1) { 
                        loopFileUpload(vendorList, id, fileArray, fileCountCheck); 
                    } else { 
                        console.log(fileCountCheck + ": Files uploaded"); 
                       } 
                }, 
                function (sender, args) { 
                    console.log("Reload List Item- Fail" + args.get_message()); 
                }); 
            }, 
            function (sender, args) { 
                console.log("Not uploaded"); 
                dfd.reject(sender, args); 
            } 
       ); 
        return dfd.promise(); 
    } 
 
    function uploadFileHolder(vendorList, id, file) { 
    debugger;
        var deferred = $.Deferred(); 
        var fileName = file.name; 
        getFileBuffer(file).then( 
            function (buffer) { 
                var bytes = new Uint8Array(buffer); 
                var binary = ''; 
                for (var b = 0; b < bytes.length; b++) { 
                    binary += String.fromCharCode(bytes[b]); 
                } 
                var scriptbase = _spPageContextInfo.webServerRelativeUrl + "/_layouts/15/"; 
                console.log(' File size:' + bytes.length); 
                $.getScript(scriptbase + "SP.RequestExecutor.js", function () { 
                    var createitem = new SP.RequestExecutor(_spPageContextInfo.webServerRelativeUrl); 
                    createitem.executeAsync({ 
                        url: _spPageContextInfo.webServerRelativeUrl + "/_api/web/lists/GetByTitle('" +vendorList+ "')/items(" + id + ")/AttachmentFiles/add(FileName='" + file.name + "')", 
                        method: "POST", 
                        binaryStringRequestBody: true, 
                        body: binary, 
                        success: fsucc, 
                        error: ferr, 
                        state: "Update" 
                    }); 
                    function fsucc(data) { 
                        console.log(data + ' uploaded successfully'); 
                        deferred.resolve(data); 
                    } 
                    function ferr(data) { 
                        console.log(fileName + "not uploaded error"); 
                        deferred.reject(data); 
                    } 
                }); 
            }, 
            function (err) { 
                deferred.reject(err); 
            } 
        ); 
        return deferred.promise(); 
    } 
    function getFileBuffer(file) {
    debugger;
        var deferred = $.Deferred(); 
        var reader = new FileReader(); 
        reader.onload = function (e) { 
            deferred.resolve(e.target.result); 
        } 
        reader.onerror = function (e) { 
            deferred.reject(e.target.error); 
        } 
        reader.readAsArrayBuffer(file); 
        return deferred.promise(); 
    } 

</script>

Multiple document upload

Uploading Multiple documents into a SharePoint document library using Javascript

<script src="https://code.jquery.com/jquery-3.2.1.js" type="text\javascript"></script>
<input type="file" id="inputFile" />
<script type="text\javascript">
var DocumentlistName="YourDocumentLibraryName";
var serverUrl = _spPageContextInfo.webAbsoluteUrl;
function uploadFile() {
debugger;
    // Define the folder path for this example.
   

    // Get test values from the file input and text input page controls.
    var fileInput = $('#inputFile');
    var newName = $('#displayName').val();
    fileCount = fileInput[0].files.length;
    // Get the server URL.
   
    var filesUploaded = 0;
    for(var i = 0; i < fileCount; i++){
        // Initiate method calls using jQuery promises.
        // Get the local file as an array buffer.
        var getFile = getFileBuffer(i);
        getFile.done(function (arrayBuffer,i) {

            // Add the file to the SharePoint folder.
            var addFile = addFileToFolder(arrayBuffer,i);
            addFile.done(function (file, status, xhr) {
                //$("#msg").append("<div>File : "+file.d.Name+" ... uploaded sucessfully</div>");
                filesUploaded++;
                if(fileCount == filesUploaded){
                    alert("All files uploaded successfully");
                    //$("#msg").append("<div>All files uploaded successfully</div>");
                    GetListItems(getListItemssuccess,getListItemsfailure);
                    $("#inputFile").value = null;
                    filesUploaded = 0;
                }
            });
            addFile.fail(onError);
        });
        getFile.fail(onError);

    }

    // Get the local file as an array buffer.
    function getFileBuffer(i) {
    debugger;
        var deferred = jQuery.Deferred();
        var reader = new FileReader();
        reader.onloadend = function (e) {
            deferred.resolve(e.target.result,i);
        }
        reader.onerror = function (e) {
            deferred.reject(e.target.error);
        }
        reader.readAsArrayBuffer(fileInput[0].files[i]);
        return deferred.promise();
    }

    // Add the file to the file collection in the Shared Documents folder.
    function addFileToFolder(arrayBuffer,i) {
    debugger;
    var index = i;

        // Get the file name from the file input control on the page.
        var fileName = fileInput[0].files[index].name;

        // Construct the endpoint.
        var fileCollectionEndpoint = String.format(
                "{0}/_api/web/getfolderbyserverrelativeurl('{1}')/files" +
                "/add(overwrite=true, url='{2}')",
                serverUrl, DocumentlistName, fileName);

        // Send the request and return the response.
        // This call returns the SharePoint file.
        return jQuery.ajax({
            url: fileCollectionEndpoint,
            type: "POST",
            data: arrayBuffer,
            processData: false,
            headers: {
                "accept": "application/json;odata=verbose",
                "X-RequestDigest": $("#__REQUESTDIGEST").val(),
                "content-length": arrayBuffer.byteLength
            }
        });
    }
}

// Display error messages.
function onError(error) {
    alert(error.responseText);
}

</script>

Tuesday 1 August 2017

For Creating a Employee Directory in SharePoint

Creating and configuring: https://en.share-gate.com/blog/corporate-directory-sharepoint-search

Adding New Properties : https://www.premierpointsolutions.com/training/help-and-how-to-articles/how-to-show-the-fax-number-in-people-search-results-in-sharepoint-2010/

Full Demo: https://www.youtube.com/watch?v=bl4NGWneFpQ

Tuesday 18 July 2017

Displaying our Twitter and Facebook feeds into SharePoint is easy and it can be achieved through


https://developers.facebook.com/docs/plugins/page-plugin

https://support.twitter.com/articles/20170071

Featured post

Data connections in Infopath forms

https://www.qdoscc.com/blog/how-automatically-retrieve-current-username-infopath-sharepoint-list-form

Popular Posts