Tuesday, February 27, 2018

SharePoint 2013 REST Send Email and Limitations

In order to send email from SharePoint Hosted App using REST, use the below code snippet.

var sendEmail = function (from, to, cc1, cc2, body, subject) {             
                var baseUrl = _spPageContextInfo.webServerRelativeUrl;
                var urlTemplate = baseUrl + "/_api/SP.Utilities.Utility.SendEmail";
                return getFormDigest().then(function (digest) {
                    $.ajax({
                        contentType: 'application/json',
                        url: urlTemplate,
                        type: "POST",
                        data: JSON.stringify({
                            'properties': {
                                '__metadata': { 'type': 'SP.Utilities.EmailProperties' },
                                'From': from,
                                'To': { 'results': [to, cc1, cc2] },
                                'Body': body,
                                'Subject': subject
                            }
                        }
                      ),
                        headers: {
                            "Accept": "application/json;odata=verbose",
                            "content-type": "application/json;odata=verbose",
                            "X-RequestDigest": $("#__REQUESTDIGEST").val()
                         
                        },
                        success: function (data) {
                            console.log("An email was sent.");
                        },
                        error: function (args) {
                            console.log("We had a problem and an email was not sent.");
                        }
                    });
                });
            };

However there are some limitations:

1. The To user must be a valid SharePoint user, cannot be a external user. For security reasons, it doesn't allow sending email to external users.

2. The user who is logging and executing this code should have manage web permissions.

SharePoint PowerShell Get InActive Sites Report

I am asked to generate a site report to identify which all site collections/ sites / sub sites are not in use for so long, so that they can be archived.

I choose to write a PowerShell script to visit all the site collections, sites, sub sites and generate a CSV report with below information. Based on the last accessed/modified date, decision making happens whether to archive/delete the site.


Site Title
Site URL
Site Users Count
Site Last Modified
Web Last Modified (item content in a web)
List Title (lists under a web)
List Items Count

Below is the PowerShell script to generate the site report.

$timestamp = get-date -format "yyyyMMdd_hhmmtt"
$filenameStart = "MSHSSiteReport"
$logfile = ("D:\{0}{1}.csv" -f $filenamestart, $timestamp)

$header = "webname,weburl,usercount,sitelastmodified,weblastmodified,archive,listname,itemcount"
$header | out-file -FilePath $logfile

$result = @()

# Get All Web Applications
$WebApps=Get-SPWebApplication
foreach($webApp in $WebApps)
{
    if(!$webApp.Url.StartsWith("https://workspace.mountsinai.org/"))
    {
        continue
    }
    Write-Host $webApp.Url -ForegroundColor Red
    foreach ($SPsite in $webApp.Sites)
    {   
        Write-Host $SPsite.Url -BackgroundColor DarkCyan
       # get the collection of webs
       foreach($SPweb in $SPsite.AllWebs)
        {
            if($SPsite.Url -eq $SPweb.Url)
            { 
                $SizeInKB = $SPsite.Usage.Storage
                $SizeInGB = $SizeInKB/1024/1024 #/1024
                $SizeInGB = [math]::Round($SizeInGB,2)
                Write-Host $SizeInGB MB -ForegroundColor Yellow
            }

            $siteTitle = $SPweb.title
            $siteUrl = $spweb.URL
            $userCount = $SPweb.Users.Count
            $siteLastModified = $SPsite.LastContentModifiedDate
            $webLastModified = $SPweb.LastItemModifiedDate
                                   
            $archive = "False"
            if($SPweb.LastItemModifiedDate -lt ((Get-Date).AddMonths(-12)))
            {
                $archive = "True"  
            }

            write-host $siteTitle ":" $siteUrl ":" $userCount ":" $webLastModified ":" $archive

            $report = New-Object System.Object
         $report | Add-Member -MemberType NoteProperty -Name "Title" -Value $siteTitle
         $report | Add-Member -MemberType NoteProperty -Name "URL" -Value $siteUrl
         $report | Add-Member -MemberType NoteProperty -Name "UserCount" -Value $userCount
         $report | Add-Member -MemberType NoteProperty -Name "SiteLastModified" -Value $siteLastModified
         $report | Add-Member -MemberType NoteProperty -Name "WebLastModified" -Value $webLastModified
         $report  | Add-Member -MemberType NoteProperty -Name "Archive" -Value $archive
         $report | Add-Member -MemberType NoteProperty -Name "List" -Value ""
         $report | Add-Member -MemberType NoteProperty -Name "ItemCount" -Value ""

         $result += $report

      Write-Host ([String]::Format("Procesing web {0}",$SPweb.Url)) -foregroundcolor Yellow
      foreach($l in $SPweb.Lists)
      {
               
           Write-Host ([String]::Format("List, '{0}', has {1} items.",$l.Title, $l.ItemCount)) -foregroundcolor Green
               
                    $report = New-Object System.Object
                 $report | Add-Member -MemberType NoteProperty -Name "Title" -Value ""
                 $report | Add-Member -MemberType NoteProperty -Name "URL" -Value ""
                 $report | Add-Member -MemberType NoteProperty -Name "UserCount" -Value ""
                 $report | Add-Member -MemberType NoteProperty -Name "SiteLastModified" -Value ""
                 $report | Add-Member -MemberType NoteProperty -Name "WebLastModified" -Value ""
                 $report | Add-Member -MemberType NoteProperty -Name "Archive" -Value $archive
                 $report | Add-Member -MemberType NoteProperty -Name "List" -Value $l.Title
                 $report | Add-Member -MemberType NoteProperty -Name "ItemCount" -Value $l.ItemCount

                 $result += $report
              
      } 

        }
    }
  }
 

$result | Export-Csv -NoTypeInformation -Path $logfile


Monday, February 19, 2018

Microsoft Azure WebJobs


WebJobs in Microsoft Azure is considered to be a feature of Azure App Service. It lets you run a program or script in the same context as a web app, API app or mobile app. Azure WebJobs is a feature provided by the cloud computing platform of Microsoft which enables you to run programs/scripts as background processes by a part of Azure websites. You can upload and run an executable file such as as cmd, bat, exe (.NET), ps1, sh, php, py, js and jar. These programs run as WebJobs on a schedule (cron) or continuously.

Here are some typical scenarios that would be great for the Windows Azure WebJobs SDK:

ü  Image processing or other CPU-intensive work.
ü  Queue processing.
ü  RSS aggregation.
ü  File maintenance, such as aggregating or cleaning up log files.
ü  Other long-running tasks that you want to run in a background thread, such as sending emails.

WebJobs are invoked in two different ways, either they are triggered or they are continuously running. Triggered jobs happen on a schedule or when some event happens and Continuous jobs basically run a while loop.
WebJobs are deployed by copying them to the right place in the file-system (or using a designated API which will do the same). 

The following file types are accepted as runnable scripts that can be used as a job:

ü  .exe - .NET assemblies compiled with the WebJobs SDK
ü  .cmd, .bat, .exe (using windows cmd)
ü  .sh (using bash)
ü  .php (using php)
ü  .py (using python)
ü  .js (using node)

After you deploy your WebJobs from the portal, you can start and stop jobs, delete them, upload jobs as ZIP files, etc. You've got full control.

A good thing to point out, though, is that Azure WebJobs are more than just scheduled scripts, you can also create WebJobs as .NET projects written in C# or whatever.

WebJobs best work with Azure Queues, Blobs, Tables and Service Bus. WebJobs SDK has built in API to listen for the incoming data into these storage systems, hence the Job will be triggered when there is a new data and process it accordingly.

Thursday, February 15, 2018

How to View SharePoint App Web Site Contents

I know most of the SharePoint App developers or users would definitely look for site contents of an App Web and List Settings in an App Web. But it turns out that there is no direct way to access the App Web Contents similar to a regular site's Site Contents.

However I have a trick to see the app web site contents by typing in the below URL as a suffix to your app web URL.
/_layouts/15/mcontent.aspx

Example: http://app-web-url/_layouts/15/mcontent.aspx

It lists all the available lists/libraries in the app web. But you will notice that the way the contents are listed is different from the regular Site Contents and by clicking on the list/library will redirects to list/library settings instead actual list. On the settings page you see the List Name which redirects to the actual list content.

Hope this post is helpful...

Monday, February 12, 2018

JQuery body append html


I wanted to append the html to body like below and the html control will be accessed in a JavaScript function.

$("body").append('<div id="vedioControl">VEDIO CONTROL</div >');

When I accessed the html control in a JavaScript function, I got an operation aborted error.
I have double checked the above statement, nothing is wrong.

Later I found that that, html will not be added to body unless the DOM is loaded.
To make sure the DOM is loaded, added the statement within the .ready function.

$(document).ready(function()
{     
      $("body").append('<div id=" vedioControl "> VEDIO CONTROL</div>');
});

Friday, February 9, 2018

Create Folder in SharePoint using REST

Here is the quick code snippet to create a folder in a Library or List using SharePoint REST.
var docLibraryName = "DocLibrary";
var folderName = "FolderTest";
var appWebUrl = "http://weburl";

var folderRelativePath = ''; //Populate with the path after folder creation to add files to folder
var folder = CreateFolder(appWebUrl, docLibraryName, folderName);
if (folder && folder.statusText && folder.statusText == 'Created') {
    if (folder.responseJSON && folder.responseJSON.d) {
        folderRelativePath = folder.responseJSON.d.ServerRelativeUrl;
    }
}

////Method to create a folder and returns folder object with metadata
CreateFolder = function (url, libraryname, foldername) {
    var folderRelPath = libraryname + '/' + foldername;
    var requestUri = url + "/_api/web/folders";
    var data = $.ajax({
        url: requestUri,
        type: "POST",
        async: false,
        data: JSON.stringify({ '__metadata': { 'type': 'SP.Folder' }, 'ServerRelativeUrl': folderRelPath }),
        headers: {
            "accept": "application/json; odata=verbose",
            "content-type": "application/json; odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val()
        },
        success: function (data) {
            alert('Folder created successfully.');
            return data;
        },
        error: function (error) {
            alert('Folder creation failed!');
            //alert(JSON.stringify(error));
            return data;
        }
    });
    return data;
}
Reference:
SharePoint REST Create Folder in Library
Creating Folder in Library using REST
REST Create Folder in SharePoint Library

Monday, February 5, 2018

SharePoint 2016 Email Event Receiver is Missing

Requirement:
I have a requirement to process the income emails into a SharePoint 2016 library. Thought of using SPEmailEventReceiver class and its features to process the email to capture Subject, Body and any Attachments in it.

Problem:
For some reason SPEmailEventReceiver class is not available in SharePoint 2016 project. Later came to know that it has been discontinued in SharePoint 2016 and cannot be used it.

Solution:
After doing some research, i came to know that the alternative for the same is Microsoft Flow.
I found a nice article on how it can be achieved is here.

Wednesday, January 24, 2018

ShareGate Issue Not Listing All Site Collections under a Web Application

Problem:
Sharegate is not listing down all the site collection under a web application, when connected to a web application.  Though the connection is made successfully.

Solution/Resolution:
It requires a separate connection for each site collection. So need to connect to a site collection before you use it for any reporting/migration.

Observation:
It could be a bug in Sharegate tool.

Thursday, January 18, 2018

SharePoint REST Get All Columns of a List

The below sample lists all the internal names columns of a list.
<script type="text/javascript">
$(document).ready(function () {
    console.log("ready!!");

$.ajax({
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('ListName')/items?$select=*",
        type: "GET",
        headers: {
            "accept": "application/json;odata=verbose",
        },
        success: function (data) {
            console.log(data.d.results);
        },
        error: function (error) {
            console.log(JSON.stringify(error));
            alert("Error occured in loading columns!");
        }
    });

});
</script>

Thursday, April 13, 2017

C# Split Comma Separated emails

private static string FormatMultipleEmailAddresses(string emailAddresses)
{
var delimiters = new[] { ',', ';' };

var addresses = emailAddresses.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

return string.Join(",", addresses);
}

Tuesday, February 2, 2016

SharePoint Server 2016 New Features

As many SharePoint Developers/Users are very much eager to know what's new in SharePoint Server 2016, I tried to list out all the newly available features (information is gathered from various Microsoft & Related blogs/forums).

Though there are various new features, the below list covers most of the major/significant features.
Please note that the features are available in SharePoint Server 2016 Beta 2 with Release Candidate.

  • Central Administration is no longer provisioned on all servers by default
  • Document Library accessibility
  • Fast Site Collection Creation
  • Zero Downtime Patching
  • Removed 5,000 View Threshold – sort of


Central Administration is no longer provisioned on all servers by default
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.

Note: You can provision or unprovision Central Administration on individual servers in a farm no matter what the server role.


Document Library accessibility
  • Keyboard shortcuts are provided for the following document tasks:
    • Alt + N - New
    • Alt + E - Edit
    • Alt + U - Upload
    • Alt + M - Manage
    • Alt + S - Share
    • Alt + Y - Synchronization
  • Focus improvements, such as keeping focus on prior elements and focus trapping.
  • Announcements for upload progress.
  • Announcements for file name and file types when browsing folder and file lists.


Fast Site Collection Creation
By using a template, a Site Collections can be created in 1 second. This compares well to SharePoint 2013 that takes up almost over 40 seconds sometimes.

This new feature provides templates that work at same level as SQL Server, which reduces the round trips required between the SharePoint and SQL servers. Use the SPSiteMaster Windows PowerShell cmdlets to create sites and site collections quickly.


File names - expanded support for special characters
SharePoint has historically blocked file names that included the &~{, and } characters, file names that contained a GUID, file names with leading dots, and file names longer than 128 characters. These restrictions are removed in SharePoint Server 2016.

NoteRestricted characters such as % and # are still not allowed in file names.


Hybrid in SharePoint Server 2016
Hybrid sites features 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.
Hybrid OneDrive for Business
Hybrid sites features are used in concert with Hybrid OneDrive for Business (introduced in SharePoint Server 2013 with Service Pack 1 (SP1)):
  • Users can sync files with Office 365 and share them with others.
  • Users can access their files directly through Office 365 from any device.
Cloud hybrid search
Cloud hybrid search is a new hybrid search solution alternative. With cloud hybrid search:
  • You index all of your crawled content, including on-premises content, to your search index in Office 365. You can set up the crawler in SharePoint Server 2016 Release Candidate to crawl the same content sources and use the same search connectors in Office SharePoint Server 2007, SharePoint Server 2010, and SharePoint Server 2013.
  • When users query your search index in Office 365, they get unified search results from both on-premises and Office 365 content.

Large file support
Though It is still not recommend storing large files in SharePoint, you can now go way beyond the previous 2GB limit for files. Though there's no real limit, Microsoft has strongly recommended it stays at 10GB. Otherwise, end users will very likely get disconnected or get a time out while uploading large files.

Note: You can configure the desired maximum file-size limit on a per-web application basis in your SharePoint farm.

MinRole farm topology
You can now install just the role that you want on particular SharePoint 2016 servers. This will only install what’s required there, but even better, it'll make sure that all servers that belong to each role are compliant. You’ll also be able to convert servers to run new roles if needed.

Mobile experience
Considering the usage of mobiles and tablets noway days, SharePoint 2016 comes with a touch friendly interface.

When you use a mobile device to access the home page for a SharePoint Server 2016 team site, you can tap tiles or links on the screen to navigate the site. You can also switch from the mobile view to PC view, which displays site pages as they are seen on a client computer.



Open Document Format (ODF) available for document libraries
The Open Document Format (ODF) enables you to create new files in a document library and save as ODF files so that users can edit the new file with a program they choose.


Sharing
  • Create and Share folder
  • Sharing Hint
  • See who the folder is shared with when viewing a folder
  • Members can share
  • Improved invitation mail
  • One-click email to approve or deny a request for access
SharePoint Search Service application
SharePoint Search supports indexing of up to 500 million items per Search Server application.


Zero Downtime Patching
Now this will surely please many of you managing the SharePoint servers, the size and number of the packages are immensely reduced. They’ve also removed the downtime previously required to update SharePoint servers.

Removed 5,000 View Threshold – virtually
A Document Library/List can have 30,000,000 documents, that’s never been an issue. However, many of you know that 5,000 seems to be the actual limit for many end users that don't know they had to index their columns.

Actually the 5,000 view threshold is actually necessary, or your entire SharePoint would be slown down. It prevents SQL to lock the entire database really.
Instead of removing this unpopular threshold, they automated the creation of Indexed Columns. This means that technically the limit is still there, but you won’t have to worry about it.

Note: Allowing automatic management of indices is configurable (on/off) through list settings.

New Compliance Center
Not only can you leverage a lot of the compliance features in Office 365 with your On-Premises SharePoint 2016, new sites have been introduced to help you stay in control.
The In-Place Policy Hold Center and the Compliance Center allow you to build your own policies and apply them against your environment. New basic policies allow you to delete data in OneDrive for Business sites after an x amount of years for example, not unlike “Retention Policies” if you think about it.

SharePoint Server 2016 Release Candidate Available

After release of SharePoint Server 2016 Beta 2 in November 2015, Recently Microsoft announced the availability of SharePoint Server 2016 Release Candidate (RC). SharePoint Server 2016 RC is mostly feature complete and represents an important milestone for customers and partners looking to deploy and evaluate SharePoint Server 2016 before general availability in Spring 2016.

You can download SharePoint Server 2016 RC via the Microsoft Download Center.

Release Candidate is an update to SharePoint Server 2016 Beta 2 and can be installed over Beta 2 only.

You can download SharePoint Server 2016 Beta 2 via the Microsoft Download Center.

Note that SharePoint Server 2016 Beta 2 is only an development evaluation version and it is not recommended for production use.

Thursday, December 10, 2015

SharePoint Custom ULS Logging

Here is a working code snippet (C# class) to write custom errors or logs to ULS log.

using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using System.Collections.Generic;

namespace CustomLogging
{
    class LoggingService : SPDiagnosticsServiceBase
    {
        public static string diagnostcAreaName = "CustomLogging";
        public static string errorPrefix = "CustomLogging: ";

        private LoggingService()
            : base("CustomLogging Logging Service", SPFarm.Local)
        {
        }

        protected override IEnumerable<SPDiagnosticsArea> ProvideAreas()
        {
            List<SPDiagnosticsArea> areas = new List<SPDiagnosticsArea>
            {
                new SPDiagnosticsArea(diagnostcAreaName, new List<SPDiagnosticsCategory>
                {
                    new SPDiagnosticsCategory("CustomLogging", TraceSeverity.Unexpected, EventSeverity.Error)
                })
            };

            return areas;
        }

        public static void LogError(string message, EventSeverity eventSeverity)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate ()
            {
                SPDiagnosticsService diagnosticService = SPDiagnosticsService.Local;
                diagnosticService.WriteTrace(0, new SPDiagnosticsCategory(diagnostcAreaName, TraceSeverity.Monitorable, eventSeverity),
                   TraceSeverity.Monitorable, errorPrefix + "{0}", new object[] { message });
            });

        }
    }
}

An entry to ULS logs can be written using the below snippet with make use of the above class.
try
{
    //Business logic
}
catch (Exception ex)
{
    LoggingService.LogError(ex.Message + " " + ex.StackTrace + "\r" + ex.Source, (EventSeverity)EventSeverity.Information);
}

Monday, August 3, 2015

SharePoint Cross Site Lookup Field

Can we create a cross site lookup field?
Yes of course, it can be. Thought it is not possible OTB, a simple trick will do this.

Scenario: Creating a cross site lookup field between the two peer web sites or sub web sites under a same site collection.
Example: Create a lookup field between two sites http:/sitecollection/webA & http://sitecollection/webB

The trick is just to set the lookup field webId with the target list webId.
Code snippet to create cross site lookup field programatically:
private bool CreateCrossSiteLookupField(SPWeb sourceWeb, SPWeb targetWeb, string sourceListTitle, string targetListtitle, string lookUpFieldName, string lookupValueColumn, bool isRequiredField)
{
    ////Get the source and target lists 
    SPList sourceList = sourceWeb.Lists.TryGetList(sourceListTitle);
    SPList targetList = targetWeb.Lists.TryGetList(targetListtitle);

    if (null != sourceList && null != targetList)
    {
        ////Add a lookup field to source list with target list as lookup list
        sourceList.Fields.AddLookup(lookUpFieldName, targetList.ID, isRequiredField);

        ////Get the created lookup field from source list 
        SPFieldLookup lookupField = (SPFieldLookup)sourceList.Fields[lookUpFieldName];

        ////Set the lookup field's webID with target list webId
        lookupField.LookupWebId = targetList.ParentWeb.ID;

        ////Set the lookup field's display field 
        lookupField.LookupField = targetList.Fields[lookupValueColumn].InternalName;

        ////Finally update the lookup field
        lookupField.Update();
    }
    return true;
}
Code snippet to create cross site lookup field with PowerShell:
Add-PSSnapIn "Microsoft.SharePoint.Powershell"

#Get the webs and lists
$webA = Get-SPWeb http://siteurl/webA/
$webB = Get-SPWeb http://siteurl/webB/
$sourceList = $webA.Lists.item("SourceList")
$targetList = $webB.Lists.item("TargetList")

#Add a lookup field to source list with target list as lookup list
$sourceList.fields.AddLookup("LookupFieldName", $targetList.id, "true")

#Get the created lookup field from source list
$lookupField = $sourceList.Fields["LookupFieldName"]

#Set the lookup field's webID with target list webId
$lookupField.LookupWebId = $targetList.ParentWeb.ID

#Set the lookup field's display field
$lookupField.LookupField = $targetList.Fields["Title"].InternalName
$lookupField.Update();

Saturday, August 1, 2015

JQuery Set Checkbox checked vs RadioButton checked

It is a common mistake or confusion on how to set value of Checkbox vs. RadioButton to checked using JQuery. Devs often use .attr method to set the value for both checkbox and radiobutton controls. Note: Using .attr on checkbox is deprecated.

However the right way to set checkbox checked is by using .prop method and radiobutton checked is by using .attr method respectively.

CHECKBOX:
$("#checkBoxCtrlId").prop("checked", true);
$("#checkBoxCtrlId").prop("checked", false);
RADIOBUTTON:
$("#radioButtonCtrlId").attr("checked", true);
$("#radioButtonCtrlId").attr("checked", false);
However same attribute will be used to check either checkbox or radiobutton is checked.
$('.checkBoxCtrlId').is(':checked');
$('.radioButtonCtrlId').is(':checked');

Thursday, July 16, 2015

How to Get Outgoing E-Mail Settings Programatically

Sometimes it might be needed to get the Web Application outgoing emails settings programatically.
The below code snippet gives all the settings including Outbound SMTP server, From address, Reply-to address and Character set information.
using (SPSite site = new SPSite("http://siteurl"))
{
    SPWebApplication webApp = site.WebApplication;
    string outboundSMTPServer = webApp.OutboundMailServiceInstance.Parent.Name;
    string fromAddress = webApp.OutboundMailSenderAddress;
    string replyToAddress = webApp.OutboundMailReplyToAddress;
    int characterSet = webApp.OutboundMailCodePage;
}
Web application outgoing email settings can also be updated programatically as below.
using (SPSite site = new SPSite("http://siteurl"))
{
    string outboundSMTPServer = "Outbound SMTP server";
    string fromAddress = "From address";
    string replyToAddress = "Reply-to address";
    int characterSet = 65001; //Character set code

    SPWebApplication webApp = site.WebApplication;
    webApp.UpdateMailSettings(outboundSMTPServer,fromAddress,replyToAddress,characterSet);
}
Similarly we can get & set the Global outgoing email settings as below.
GET:
var globalAdmin = SPAdministrationWebApplication.Local;
var outboundSMTPServer = globalAdmin.OutboundMailServiceInstance.Parent.Name;
var fromAddress = globalAdmin.OutboundMailSenderAddress;
var replyToAddress = globalAdmin.OutboundMailReplyToAddress;
var characterSet = globalAdmin.OutboundMailCodePage;
SET:
string outboundSMTPServer = "Outbound SMTP server";
string fromAddress = "From address";
string replyToAddress = "Reply-to address";
int characterSet = 65001; //Character set code
var globalAdmin = SPAdministrationWebApplication.Local;
globalAdmin.UpdateMailSettings(outboundSMTPServer, fromAddress, replyToAddress, characterSet); 

Wednesday, July 15, 2015

SharePoint AutoComplete Lookup Field with JQuery

Created a Custom SharePoint Lookup field that offers new functionalities to default SharePoint lookup field by allowing Auto Complete or Type Ahead search functionality with Contains CAML query.
Below is a few of the features offered by AutoComplete Lookup field over standard SharePoint Lookup field:
  • Auto Complete or Type Ahead lookup search (queries after each typing)
  • OTB SharePoint Lookup Dropdown look and feel for the results 
  • Proper validations
  • Searches the lookup keyword with Contains CAML query
  • Configurable for No.of results to be displayed
  • Configurable for No.of characters to start the auto complete search
Limitations:
  • It cannot be multi-valuated
  • Only one AutoComplete Lookup field is allowed per list
  • The target lookup field is frozen and always the Title field
The project is packaged as a Windows installer using the SharePoint Solution installer; to install, simply run setup.exe. The software is available on CodePlex here.
AutoComplete Lookup - Create Column
AutoComplete Lookup - Configure Column
AutoComplete Lookup - Results Display

Please do let me know if you find any issues or bugs or useful enhancement that could be added.

Monday, July 13, 2015

SharePoint ListItem Update vs SystemUpdate vs UpdateOverwriteVersion

Here is a simple table format to explain the differences among Update vs SystemUpdate vs UpdateOverwriteVersion vs SystemUpdate(true). 

This information is pretty much useful to look at the differences between the following SPListItem methods when working with event receivers or workflows.


Update()
SystemUpdate()
SystemUpdate(true)
UpdateOverwriteVersion()
Updates the item in the database
ü  
ü  
ü  
ü  
Creates a new version
ü  
û   
ü  
û   
Updates the Modified and Modified By values
ü  
û   
û   
ü