Showing posts with label SharePoint Online. Show all posts
Showing posts with label SharePoint Online. Show all posts

Thursday, March 28, 2019

SharePoint - Cannot convert a primitive value to the expected type 'Edm.Double'. See the inner exception for more details


If you see this kind of error, make sure that is because the value which you are passing doesnt match with the data type present in the sharepoint list column

make sure what ever you are sending to sharepoint list matches the column data type, to figure out which column is causing the error, remove one by one column/filed in the item which you are passing or else you can check the error.responseText in error

Wednesday, March 27, 2019

Getting tasks and sub-tasks from task list using SharePoint 2013/SP online and rest API


var fullurl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Project%20Tasks')/items?$select=*,ParentID/Id,Predecessors,Predecessors/Id&$expand=ParentID,Predecessors";
    $.ajax 
({ 
url: fullurl, 
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
},
success: function (data) {
var items = data.d.results.length;
if(items > 0) 

var tasks = data.d.results; 

jsonObj = [];
var mainTasks = [], subTasks = [];
$.each(tasks, function (index, task) {
if(task.ParentID.Id) {
item = {}
item ["ParentID"] = task.ParentID.Id
item ["Title"] = task.Title
item ["Priority"] = task.Priority
item ["DueDate"] = task.DueDate
item ["StartDate"] = task.StartDate
item ["PercentComplete"] = task.PercentComplete
item ["Status"] = task.Status
subTasks.push(item);
} else {
item = {}
var startdate = $.datepicker.formatDate( "dd-mm-yy", new Date(task.StartDate));
var duedate = $.datepicker.formatDate( "dd-mm-yy", new Date(task.DueDate));
item ["ID"] = task.Id
item ["Title"] = task.Title
item ["Priority"] = task.Priority
item ["DueDate"] = duedate
item ["StartDate"] = startdate
item ["PercentComplete"] = task.PercentComplete
item ["Status"] = task.Status
mainTasks.push(item);
}
});
},
error: function (error) {
alert(JSON.stringify(error));
}
});  

Friday, February 10, 2017

Suggestions or Auto populate values in textbox using JQuery and C#(SharePoint 2013)


I have done this on SharePoint application page which is deployed under layouts folder, this can be also used in .net applications.
below is images shows you populated suggestions that are saved in database


First fill the data inside a gridview/table with fields that you need to auto populate
this can be done based on your coding capabilities

once you do it hide the table so that anyone cannot see it using CSS or code in my case i did with CSS
.GridHide is my class for hiding gridview and below other two classed is used to autocomplete list

<style type="text/css">
.GrdHide {
            display:none;
        }
        ul.ui-autocomplete {
    list-style: none;
}
.ui-autocomplete {
    height: 200px;
    overflow-y: scroll;
    overflow-x: hidden;

}
</style>

Code in JQuery to populate table data inside textbox i did this for two textboxes for project name and project number you can repeat the same as many columns you want

function GetData() {
            var MYProjNumb = new Array();
            var MYProjName = new Array();

            var table = $("#ctl00_PlaceHolderMain_hiddenGrd tbody"); //my table ID

            table.find('tr').each(function (i) {
                var $tds = $(this).find('td'),
                    ProjectNumber = $tds.eq(0).text(),
                    ProjectName = $tds.eq(1).text(),


                //alert('Row ' + (i + 1) + ':\npNumber: ' + ProjectNumber
                //      + '\nPName: ' + ProjectName);
                MYProjNumb.push(ProjectNumber);
                MYProjName.push(ProjectName);

            });
            ProjNumber(MYProjNumb);
            ProjName(MYProjName);
        }
        function ProjNumber(list) {
            var PJlst = GetUnique(list);
            $("[id*=txtProjNum]").autocomplete({
                source: PJlst,
                select: function (event, ui) {
                }
            });
        }
        function ProjName(list) {
            var PNLst = GetUnique(list);
            $("[id*=txtProjectName]").autocomplete({
                source: PNLst,
                select: function (event, ui) {
                }
            });
        }

to display only unique values in auto suggestion box then use the below code

        function GetUnique(list)
        {
            var unique = list.filter(function (itm, i, a) {
                return i == a.indexOf(itm);
            });
            return unique;
        }

call the above GetData() method on load of page

    <script type="text/javascript">
        $(function () {
            GetData();
});
</script>

all set...now you have auto populate textboxes on your page
limit your table data to 50 so that page loads faster.

Thursday, August 11, 2016

Minimizing/hiding sub tasks on a tasks list in office 365


By default sharepoint will show all the subtask on a tasks list to minimize them use the below script by adding script editor webpart on tasks pages

<script src="https://sharepointsiteurl/SiteAssets/JS%20file/jquery-1.9.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $(".ms-commentcollapse-icon").click();

        });
</script>

Saturday, July 23, 2016

Workflows getting suspended when sending emails outside company domain using SharePoint designer in O365


SharePoint 2013 designer workflows does not allow users to send emails out side their company domain the alternative is to start 2010 workflow from 2013 with email functionality or degrade the workflow version to 2010

Wednesday, July 13, 2016

Retrieving all list items from a list which has crossed threshold limit in O365/sharepoint online using REST


To retrieve list item from a list which has already crossed the threshold limit i.e. 5000 items in 0365
this can only be done if we have indexed the list previously, i mean we can only query a list which has indexed column which has been created while list creation, in office 365 we cannot increase the threshold limit more than 5000 but we have an option to do that in on perm for up to 20000 items

increasing a threshold limit is not suggested by Microsoft, this will effect the performance, the only option to do this is to pull up data from a large list(more than 5000) in batches, you can batch data up to 4999 in once rest call and need to run untill the total count of the list completes

in the below code "ArchivedList" object will store all the items from a list in batch basis
use the script editor webpart to check this code.

<script src="https://yoursharepointsite/SiteAssets/Java%20Script%20Files/jquery-1.10.2.js"></script>  
<script type="text/javascript">
var ArchivedList = [];
var ListTest=[];
var i=0;
$(document).ready(
       function () {

           var spHostUrl = "https://yoursharepointsite";
           //Build absolute path to the layouts root with the spHostUrl
           var layoutsRoot = spHostUrl + '/_layouts/15/';
           $.getScript(layoutsRoot + "SP.Runtime.js", function () {
               $.getScript(layoutsRoot + "SP.js", getListData);
           }
           ); 
       }
     );
function getDataFromUrl(endpoint) {
     return jQuery.ajax({
         url: endpoint,
         method: "GET",
         headers: {
             "Accept": "application/json; odata=verbose",
             "Content-Type": "application/json; odata=verbose"
         }
     });
}
function getLargeList(nextUrl) {
     var dfd = new $.Deferred();
     if (nextUrl == undefined) {
         dfd.resolve();
         return;
     }
     getDataFromUrl(nextUrl).done(function (listItems) {
         var items = listItems.d.results;
          ListTest=items;
          ArchivedList=ArchivedList.concat(ListTest);
         var next = listItems.d.__next;
   
         $.when(getLargeList(next)).done(function (){
             dfd.resolve();
         });
     });
     return dfd.promise();
}
function getListData() {
     var documentLibName = 'Archived';
     
     https://yoursharepointsite/_api/web/lists/getbytitle(documentLibName)/items?$select=Title,No_Days,Current_x0020_State,Form_x0020_Type,Modified,ContentType/Name,ContentType/Id&$expand=ContentType&$filter=(Modified ge '"+strtDate +"' and Modified le '"+endDate+"') and startswith(ContentTypeId,'0x0120') &$top=200
     var listServiceUrl1= _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Archived')/Items?$Select=Title,No_Days,Current_x0020_State,Form_x0020_Type,Modified,ContentType/Name,ContentType/Id&$expand=ContentType&$filter=startswith(ContentTypeId,'0x0120')&$top=200";
     
     
     
     var listServiceUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('" + documentLibName + "')/Items?$Select=Title,No_Days,Current_x0020_State,Form_x0020_Type,Modified,ContentType/Name,ContentType/Id&$expand=ContentType&$top=200";
     $.when(getLargeList(listServiceUrl)).done(function () {
            alert(ArchivedList.length);
 });
 }

</script> 

Deleting data from workflow history list using JSON 

copy past the below code in script editor webpart.

<script src="https://sharepoint_yoursite/subsitename/SiteAssets/Java%20Script%20Files/jquery-1.10.2.js"></script>
    <script type="text/javascript">
var clientContext;
var website;
var oList;
var cnt = 0;
var collListItem;
// Make sure the SharePoint script file 'sp.js' is loaded before your code runs.
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);

// Create an instance of the current context.
function sharePointReady() {
    clientContext = SP.ClientContext.get_current();
    website = clientContext.get_web();
    oList = website.get_lists().getByTitle('Workflow History');

    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml('<View><RowLimit>1000</RowLimit></View>');
    this.collListItem = oList.getItems(camlQuery);

    clientContext.load(website);
    clientContext.load(collListItem, 'Include(Id)');
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded(sender, args) {

    var listItemInfo = '';
    var listItemEnumerator = collListItem.getEnumerator();

    while (listItemEnumerator.moveNext()) {
        var oListItem = listItemEnumerator.get_current();
        var ID = oListItem.get_id();
        var oListItemDel = oList.getItemById(ID);
        oListItemDel.deleteObject();
        clientContext.executeQueryAsync(Function.createDelegate(this, this.onDeleteSucceeded), Function.createDelegate(this, this.onDeleteFailed));
        console.log(ID + " : Deleted");
    }
}

function onQueryFailed(sender, args) {
    console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}


function onDeleteFailed(sender, args) {
    console.log('Delete failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

function onDeleteSucceeded(sender, args) {
    cnt = cnt + 1;
    console.log('Delete success : ' + cnt);
}
</script> 

Saturday, June 18, 2016

SharePoint 2016: New site contents experience


I though of you showing all new site content which is going to come up in SharePoint 2016, below is the new look :)




New features in SharePoint 2016

I am listing down some of the import new features for SharePoint 2016, i believe you find this interesting, all the references are from MSDN


·        Fast site collection creation using PowerShell command "SPSiteMaster"
·        SharePoint Server 2016 Central Administration is now provisioned on the first server in a farm by default when using the SharePoint Products Configuration Wizard. Central Administration is not provisioned on additional servers in a farm by default.
You can provision or un-provision Central Administration on individual servers in a farm, no matter what the server role is by using the following methods:
·        The Services on Server page on Central Administration > System Settings
·        Windows PowerShell cmdlets:
New-SPCentralAdministration
Remove-SPCentralAdministration
·        The psconfig.exe -cmd adminvs operation
The SharePoint Products Configuration Wizard
Hybrid sites features
This feature allows your users to have an integrated experience while using SharePoint Server and SharePoint Online sites:
·        Users can follow SharePoint Server and SharePoint Online sites, and see them consolidated in a single list.
·        Users have a single profile in Office 365, where all of their profile information is stored.
Large file support
·        Previous versions of SharePoint did not support uploading or downloading files larger than 2,047 MB. SharePoint 2016 now allows you to upload or download larger files. You can configure the desired maximum file-size limit on a per-web application basis in your SharePoint farm.
·         
SharePoint Foundation is no longer available in the SharePoint Server 2016 release.


SharePoint Server 2016 doesn't support the standalone install option, so it is no longer available in the setup program. Use the MinRole during installation and choose one of the available install options. The Single Server Farm option where everything is installed on the same computer is supported for dev/test/demo purposes. When you use this option, you must install SQL Server yourself and then run the SharePoint Server 2016 farm configuration wizard

ForeFront Identity Manager client (FIM)

Earlier versions of SharePoint used ForeFront Identity Manager client (FIM) to synchronize between Active Directory and SharePoint. SharePoint Server 2016 no longer uses FIM as the synchronization client. The default process is Active Directory Import. You can also use any synchronization tool such as Microsoft Identity Manager 2016, or any third-party tool.


Excel Services in SharePoint
Excel Services and its associated business intelligence capabilities are no longer hosted on SharePoint Server. Excel Services functionality is now part of Excel Online in Office Online Server (this is the next version of Office Web Apps Server), and SharePoint users can use the services from there
If you currently use Excel Services in SharePoint 2013 and upgrade to SharePoint Server 2016 you must also deploy Office Online Server with Excel Online to ensure Excel Services functionality remains available.
Mini Roles
By using the new MinRole feature in SharePoint Server 2016, SharePoint farm administrators can define each server’s role in a farm topology. The role of a server is specified when you create a new farm or join a server to an existing farm. SharePoint automatically configures the services on each server based on the server's role, and the performance of the farm is optimized based on that topology.
Server role
Description
Front-end
Service applications, services, and components that serve user requests belong on Front-end web servers. These servers are optimized for low latency.
Application
Service applications, services, and components that serve backend requests (such as background jobs or search crawl requests) belong on Application servers. These servers are optimized for high throughput.
Distributed cache
Service applications, services, and components that are required for a distributed cache belong on Distributed Cache servers.
Search
Service applications, services, and components that are required for searching belong on Search servers.
Custom
Custom service applications, services, and components that do not integrate with MinRole belong on Custom servers. The farm administrator has full control over which service instances can run on servers assigned to the Custom role. MinRole does not control which service instances are provisioned on this role.
Single-server farm
Service applications, services, and components required for a single machine farm belong on a Single-Server Farm. A Single-Server Farm is meant for development, testing, and very limited production use. A SharePoint farm with the Single-Server Farm role cannot have more than one SharePoint server in the farm.


 

SharePoint 2016: New document library experience in O365/SharePoint online


Today morning i have seen a popup asking to experience the new document library changes in our company website, check the new changes for document libraries, hope you love this.






Now we can see folders in a list or in a tiles view and change the metadata fields and save it as a view









Wednesday, June 15, 2016

Error: Sorry something went wrong...the file … has been modified by … on in document library or document set

Issue: i am seeing the above error while updating an item inside document library with document set content type, it is happening while updating the item using JQuery code in office 365 with REST calls, and i am do that update for checking out(updating a custom column called checkout) document set and then updating the field columns, so i am seeing this error for the second update of item properties for a document set.

Resolution:

I have resolved this issue by removing the versioning from that particular document library
and the also unchecked the "Automatically update the workflow status to the stage name" and the other JQuery code change which may help resolving the issue is to reload the list before doing a second update using CSOM


Thursday, September 3, 2015

New Features in SharePoint 2016


  1. Role based configuration wizard for configuring a server role

  • Front end 
  • Application
  • Search
  • Specialized load
  • Distributed cache
  1. Zero downtime patching
  2. App launcher for on premise has been introduced
  3. Office 365 api's coming to On-premise 
  4. No Standalone machine any more there should be two servers two install SharePoint now one for SharePoint and other for Sql server
  5. No Foundation version any more
  6. Build one and deploy into two environments(for one premise and office 365)

Tuesday, September 1, 2015

Debugging Remote Event Recievers

  1. We must create a new azure service bus namespace using azure powershell
  2. The command give back a connection sting to connect to Azure environment with EndPoint
  3. Use this in visual studio for connecting to azure
  4. go to project properties
  5. inside that go to SharePoint tab
  6. Check the enable debugging via Azure service bus
  7. copy past the connection string that we got from command prompt
  8. insert a breakpoints and click on F5 for debugging

Remote event receivers in SharePoint 2013


The remote events supports

Site - Create, Move, Delete
List - Create, Delete
List schema - Create, Update, Delete
List Item - Create, Update, Delete, Move, CheckIn, UnCheckIn, CheckOut, AttachmentsAdded, AttachemntsRemoved, FileMoved, FileConverted
App - Install, Update, Uninstall

Some Impotent Points to be noted:
  • Remote event receivers call across the networks
  • After events use WCF(Windows communication foundation) call on remote web so that they do not block the sharepoint host nor delay the response back to the user
  • Remote event recievers will only workf if the concern list is present in App Web
  • SharePoint hosted apps doesnt support remote event receievers, its only provider hosted apps
  • IRemoteEventService an interface thats get inherited in remote event recievers
  • We have only two events called "ProcessEvent" which is a two way event and "ProcessOneWayEvent" for one way
  • Properties argument defines the event that has fired on a list item
  • We will be having only single entry point for all the events
  • Properties.ItemEventProperties is for an item events and Properties.ListEventProperties for list events
  • SPRemoteEventResult which is used to sent status back to SharePoint(used for sending information and also for canceling the events)


Before events example

After events example



  • App Life Cycle events are two way events
  • "ProcessOneWayEvent" never file in App related events
This are just brief points about remote event recievers.

SharePoint - Cannot convert a primitive value to the expected type 'Edm.Double'. See the inner exception for more details If y...

Ad