Showing posts with label Script. Show all posts
Showing posts with label Script. Show all posts

Sunday, September 6, 2015

Delete a list items using JavaScript library code in SharePoint 2013

Would like to delete 13000+ records from the list in SPO.
SCRIPT  BEGIN
var itemId;
var oListItem;
 $(document).ready(function() {
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);

    });

function sharePointReady(){
    var clientContext = new SP.ClientContext("XXX");
    var oList = clientContext.get_web().get_lists().getByTitle('Workflow History');
for LOOP
{
    this.oListItem = oList.getItemById(itemId);
    oListItem.deleteObject();

    clientContext.executeQueryAsync(
        Function.createDelegate(this, this.onQuerySucceeded),
        Function.createDelegate(this, this.onQueryFailed)
    );
}
}
SCRIPT END
https://msdn.microsoft.com/en-us/library/office/jj163201.aspx#BasicOps_SPListItemCRUD

Wednesday, April 8, 2015

Hide or show list form fields in SharePoint using jQuery

David Lozzi has written a jquery library which is useful our daily development activites.
http://davidlozzi.com/2014/01/14/sharepoint-2013-script-hide-or-disable-your-fields
ExecuteOrDelayUntilScriptLoaded(function(){
  Lozzi.Fields.disableWithAllowance("Employee Name",["LeaveEntryAuthorization"]);

  },"sp.js");
sp.js should load before execute the code.