Wednesday, November 4, 2015

SharePoint Blogs: List view issues with lookup and workflow columns

SharePoint Blogs: List view issues with lookup and workflow columns: Hi, I found an issue in my project when the number of lookup and workflow columns exceeded the limit. Please see below. I reduced t...

List view issues with lookup and workflow columns

Hi,

I found an issue in my project when the number of lookup and workflow columns exceeded the limit.
Please see below.


I reduced the no. of columns in the list view and afterwards it worked fine. The list view was displaying the columns without the above error.

Thanks,
Kunal

Wednesday, October 14, 2015

Monday, October 12, 2015

Footer links web part

Hi Folks,

I contributed to a reusable component for my team's contribution project. Using ecma script, we are fetching data from SharePoint list and displaying it to Script editor web part. We did some sorting/filtering using Caml query.

List Settings:


Output:

FooterTest.aspx
more > is navigating to NavigatePage.aspx.
NavigatePage.aspx


Common CSS Used for "FooterTest.aspx" and "NavigatePage.aspx":
<style>
.outerDiv
{
       width:1100px;
       margin-top:10px;
       border-top:1px solid #ccc;
       padding:10px 0 0;
       clear:both;
}
.col {  
         float: left;
         padding: 30px 0 0 35px;
  width: 310px
}
.col li{
  text-decoration:none;
}

.col ul
{
  float:left;
  list-style: none;
  margin: 0;
  padding: 0;
  border-top:1px solid #0B0719;
}
.col li
{
  border-bottom: 1px dotted #BDBDBD;  
  float: left;
  height: 35px;
  margin: 3px 0;
  padding: 0;
  width: 310px;
}
.col li:last-child
{
    border:none;
}
.col li a
{    
  color: black;
  display: block;
  float: left;
         font: normal 12px Arial;
  padding: 10px 0 0 19px;
  text-decoration: none;
}
</style>





Ecma Script Used for "FooterTest.aspx"
1   <script type="text/javascript" src="../../SiteAssets/jquery-1.11.1.js"></script>
<script type="text/javascript" src="../../SiteAssets/jquery-1.11.1.min.js"></script>
<script language="javascript" type="text/javascript">
    var clientContext;
    var website;
    var list;
    var items;
    var html = '<div class="col"><ul>';
    var index = 0;
    var lIndex = 0;
    // 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();
        list = website.get_lists().getByTitle('TestFooter');
        var camlQuery = new SP.CamlQuery();
        camlQuery.set_viewXml('<View><Query><Where><And><Eq><FieldRef Name=\'IsActive\'/>' +
        '<Value Type=\'Boolean\'>1</Value></Eq><IsNotNull><FieldRef Name=\'Url\'/></IsNotNull></And></Where><OrderBy><FieldRef Name=\'DisplayOrder\' Ascending=\'TRUE\' /></OrderBy></Query></View>');
         items = list.getItems(camlQuery);
        clientContext.load(items);      
        clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
    }
    function onRequestSucceeded() {
        var itemCount = items.get_count();
        console.log(itemCount);
        var enumerator = items.getEnumerator();
        while (enumerator.moveNext()) {           
            var listItem = enumerator.get_current();
            var rotatorTitle = listItem.get_item('Title');
            var rotatorUrl = listItem.get_item("Url");
            var rotatorIsActive = listItem.get_item('IsActive');
            GetData(rotatorTitle, rotatorUrl);
        }      
        $("#siteOwner").append(html);       
    }
    function onRequestFailed(sender, args) {
        alert('Error: ' + args.get_message());
    }

    function GetData(rotatorTitle, rotatorUrl) {
        if (lIndex < 16) {
                if (index <= 4) {
                    html += "<li><a href=" + rotatorUrl + ">" + rotatorTitle + "</a></li>";
                    index++;
                    lIndex++;
                }
                else if (lIndex == 15) {                  
                    html += '<li><a href="https://accobrands.sharepoint.com/ITCompliance/Pages/NavigatePage.aspx"> more > </a></li></ul></div>';
                    lIndex++;
                }
                else {
                    index = 0;
                    html += '<li><a href=' + rotatorUrl + '>' + rotatorTitle + '</a></li></ul></div><div class="col"><ul>';
                }
            }
            else {
                //No action needed
            }
       
    }
</script>
<div id="siteOwner" class="outerDiv">

</div>





Ecma Script Used for "NavigatePage.aspx"
<script type="text/javascript" src="../../SiteAssets/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../../SiteAssets/jquery-1.11.1.min.js"></script>
<script language="javascript" type="text/javascript">
    var clientContext;
    var website;
    var list;
    var items;
    var html = '<div class="col"><ul>';
    var index = 0;
    var lIndex = 0;
    var mIndex = 0;
    // 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();
        list = website.get_lists().getByTitle('TestFooter');
        var camlQuery = new SP.CamlQuery();
        camlQuery.set_viewXml('<View><Query><Where><And><Eq><FieldRef Name=\'IsActive\'/>' +
        '<Value Type=\'Boolean\'>1</Value></Eq><IsNotNull><FieldRef Name=\'Url\'/></IsNotNull></And></Where><OrderBy><FieldRef Name=\'DisplayOrder\' Ascending=\'TRUE\' /></OrderBy></Query></View>');
        items = list.getItems(camlQuery);
        clientContext.load(items);
        //clientContext.load(website);
        clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
    }
    function onRequestSucceeded() {
        var itemCount = items.get_count();
        console.log(itemCount);
        mIndex = itemCount - 4;
       
        var enumerator = items.getEnumerator();
        while (enumerator.moveNext()) {
            var listItem = enumerator.get_current();
            var rotatorTitle = listItem.get_item('Title');
            var rotatorUrl = listItem.get_item("Url");
            var rotatorIsActive = listItem.get_item('IsActive');
            GetData(rotatorTitle, rotatorUrl);
        }
        $("#siteOwner").append(html);
        //alert(website.get_url());
    }
    function onRequestFailed(sender, args) {
        alert('Error: ' + args.get_message());
    }

    function GetData(rotatorTitle, rotatorUrl) {       
            if (index <= 4) {
                html += "<li><a href=" + rotatorUrl + ">" + rotatorTitle + "</a></li>";
                index++;
                lIndex++;
            }
            else if (lIndex == mIndex) {
                html += '<li><a href=' + rotatorUrl + '>' + rotatorTitle + '</a></li></ul></div>';
            }           
            else {
                index = 0;
                html += '<li><a href=' + rotatorUrl + '>' + rotatorTitle + '</a></li></ul></div><div class="col"><ul>';
            }
    }
</script>
<div id="siteOwner" class="outerDiv">
   
</div>

Display list data in jQuery tables without using Data View web part

Hi folks,

I did a small POC in my project to fetch data using REST API and feed the results into jQuery data tables. Using this we can apply sorting, paging, filtering to the results received.
Please check the code below.

<script type="text/javascript" charset="utf8" src="../SiteAssets/Scripts/jquery-1.11.3.min.js"></script>
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.7/css/jquery.dataTables.min.css">

Job Status: <input type="text" id="Status">

<input type="button" value="Get Records" onclick="LoadRecords($('#Status').val());" >

<table width="100%" cellpadding="0" cellspacing="0" border="0" class="display" id="example">
<thead>
<th>Job Name</th>
<th>Job Status</th>
<th>Source</th>
<th>Client Number</th>
</thead>
</table>

<script type="text/javascript">
console.log(_spPageContextInfo.webAbsoluteUrl);
function LoadRecords(state)
{
var call = $.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('SAP Batch Jobs')/items?$select=Job_x0020_Name,Title,Source,Client_x0020_Number&$filter=(Title eq '"+state+"')&$top=5000",
type: "GET",
dataType: "json",
headers: {
Accept: "application/json;odata=verbose"
}
});
call.done(function (data,textStatus, jqXHR){

$('#example').dataTable({
"bDestroy": true,
"bProcessing": true,
"aaData": data.d.results,
"aoColumns": [
{ "mData": "Job_x0020_Name" },
{ "mData": "Title" },
{ "mData": "Source" },
{ "mData": "Client_x0020_Number" }
]
});

});
call.fail(function (jqXHR,textStatus,errorThrown){
alert("Error retrieving Tasks: " + jqXHR.responseText);
});
}
</script>

For complete details of jQuery plugin, please check the below link
http://summit7systems.com/who-needs-a-data-view-web-part-sharepoint-rest-and-datatables-net/

Monday, August 31, 2015

SharePoint Designer 2013 Workflows: Best Practices to follow

Rules to follow while working on SharePoint Designer workflows. It can prevent you to recreate the workflow from scratch once the workflow became corrupt.
(Can also refer 'http://blog.eastridge.net/sharepoint-designer-2013-worklows-copy-paste-and-delete-best-practices')

  • Never delete a stage before deleting all actions and conditions within that stage first.
  • Never delete a stage if another stage is transitioning to it. Make sure to modify the transition portion of the other stage first.
  • Never copy and paste a stage. Create the stage manually and then copy and paste the actions into the new stage.
  • Never delete an "IF" or "ELSE" without first deleting all the actions in the condition first.
  • Never copy and paste an "IF" or "ELSE" block. Create the "IF" and "ELSE" conditions manually and then copy and paste the actions into the condition.
  • Take backups of your workflow often using the "Save as Template" feature described here, http://msdn.microsoft.com/en-us/library/office/jj819316(v=office.15).aspx. This will allow you to rule back to the last backup if your workflow did get corrupted.

Wednesday, August 5, 2015

Navigate SharePoint List Save button to different page.

Hi,

We got a small task to navigate SharePoint list form to different page after click of "Save" button.

Please follow the below steps.
1. Open the SharePoint list form in designer.

2. Search for the below tag. Comment it.
<SharePoint:SaveButton runat="server" ControlMode="New" id="savebutton1"/>
As we had task on custom NewForm.aspx so we applied in this page.

3. Add the below code for new Save button.
<input type="button" value="Save" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={https://accobrands.sharepoint.com/sites/ITRequestTool/Pages/MyRequests.aspx}')}" />

4. Save the form and Open it in browser. You will get the proper navigation as expected.

You can also prefer the below link.
http://beginnerssharepointtips.blogspot.in/2014/07/redirecting-to-page-from-list-form.html 


Thanks,