Monday, 20 April 2015

How to make attachment mandatory in SharePoint list form?

Using a list item it is not possible to make the attachment required out of the box. To make this field mandatory we will need to add JavaScript on list form.

Below is the java script which will make attachment field mandatory on list form


<script type="text/javascript" language="javascript">
function PreSaveAction() 

{
    var elm = document.getElementById("idAttachmentsTable");
    if (elm == null || elm.rows.length == 0)
    {

       document.getElementById("idAttachmentsRow").style.display='none';
       alert("Please attach Documents");
       return false ;
    }
    else
    { 
      return true ;
    }
}
</script>


Hope this helps.

Ref: https://social.technet.microsoft.com/Forums/sharepoint/en-US/c93d7611-f634-4c03-ae0d-3b5ecfe5ca6a/how-to-make-attachment-required-field


Friday, 17 April 2015

CSOM vs JSOM vs SSOM vs REST


2013

Model Types:
  • CSOM: Client-side object model. C# (or Visual Basic) only, use NuGet, at the moment same package for both 2010 and 2013.
  • JSOM: JavaScript object model. JavaScript only.
    • SP.ClientContext.get_current() for normal use. new SP.ClientContext('url...') for specific SPSite. Note this works cross-SPSite in 2013.
  • SSOM: Server-side object model. C# (or Visual Basic) only, use Microsoft.SharePoint (15) DLL. Must be deployed on same farm.
  • REST: REST web technologies and standard Open Data Protocol (OData) syntax.
Hosting:
  • SharePoint hosted: JavaScript and templates only. By templates I mean list templates, content types, etc. Anything that can be uploaded to the SharePoint virtual file system can also be added, such as .aspx-pages.
  • Autohosted: C# (or Visual Basic) only. Currently only supported on Office 365. On app purchase an Azure instance will be automatically provisioned. Uses OAuth to comunicate to SharePoint site.
  • Provider hosted: C# (or Visual Basic). Similar to Autohosted, but is meant to be hosted more manually (i.e. On Azure). So you fire up a web application, on any server, and then use S2S to connect to SharePoint.
  • Sandboxed: Remnant from 2010, can be uploaded to Solution gallery. Support for limited subset of the SSOM. No file access, so can not deploy anything to _layouts folder. If you use the limited SSOM-part (C#) your solution will be considered deprecated. Support for templates such as list templates and content types, deployed directly to host web.
  • Farm solution: Full access, deploy through PowerShell.
Technologies table:
+--------------------------------------------------------+
¦               ¦ CSOM ¦ JSOM ¦ SSOM ¦ REST JS ¦ REST C# ¦
¦---------------+------+------+------+---------+---------¦
¦ JavaScript    ¦      ¦  x   ¦      ¦  x      ¦         ¦  
¦ C#            ¦      ¦      ¦  x   ¦         ¦  x      ¦  
¦ From browser  ¦      ¦  x   ¦      ¦  x      ¦         ¦  
¦ From server   ¦  x   ¦      ¦  x   ¦         ¦  x      ¦  
¦ OAuth2        ¦  x   ¦  x   ¦  x   ¦  x      ¦  x      ¦  
¦ S2S           ¦  x   ¦      ¦  x   ¦         ¦         ¦ 
+--------------------------------------------------------+
Hosting table:
+---------------------------------------------------------------------+
¦                     ¦ CSOM ¦ JSOM ¦ SSOM        ¦ REST JS ¦ REST C# ¦
¦---------------------+------+------+-------------+---------+---------¦
¦ SharePoint hosted   ¦      ¦  x   ¦             ¦         ¦         ¦
¦ Autohosted          ¦  x   ¦      ¦             ¦         ¦  x      ¦ 
¦ Provider hosted     ¦  x   ¦      ¦             ¦         ¦         ¦ 
¦ Sandboxed solution  ¦  x   ¦  x   ¦  x(limited) ¦  x      ¦  x      ¦
¦ Farm solution       ¦  x   ¦  x   ¦  x          ¦  x      ¦  x      ¦ 
+---------------------------------------------------------------------+

2010

Model Types:
  • CSOM: Client-side object model. C# (or Visual Basic) NuGet and JavaScript.
    • SP.ClientContext.get_current() for normal use. new SP.ClientContext('url...') for specific SPWeb.
  • SSOM: Server-side object model. C# (or Visual Basic) only, use Microsoft.SharePoint (14) DLL. Must be deployed on same farm.
  • REST: REST in 2010 is only for ListData.svc. Note that SPServices (jQuery plugin) utilizes the.asmx services in _/vti/bin , such as /_vti_bin/Webs.asmx
Technologies table:
+-------------------------------------+
¦               ¦ CSOM ¦ SSOM ¦ REST  ¦
¦---------------+------+------+-------¦
¦ JavaScript    ¦  x   ¦      ¦  x    ¦  
¦ C#            ¦  x   ¦  x   ¦  x    ¦  
¦ From browser  ¦      ¦  x   ¦  x    ¦  
¦ From server   ¦  x   ¦  x   ¦       ¦  
+-------------------------------------+
Hosting table:
+---------------------------------------------------------------------+
¦                     ¦ CSOM ¦ JSOM ¦ SSOM        ¦ REST JS ¦ REST C# ¦
¦---------------------+------+------+-------------+---------+---------¦
¦ Sandboxed solution  ¦  x   ¦  x   ¦  x(limited) ¦  x      ¦  x      ¦
¦ Farm solution       ¦  x   ¦  x   ¦  x          ¦  x      ¦  x      ¦ 
+---------------------------------------------------------------------+
Ref: http://sharepoint.stackexchange.com/questions/93269/csom-vs-jsom-vs-ssom-vs-rest



Monday, 9 February 2015

Open PDF files in browser - SharePoint (Secure Way)

SharePoint 2010 prompts to save PDF documents when opening.

Most of the blogs will offer you a solution to change the Browser File Handling property to Permissive in Central Administration for that particular web application.

First of all there are good reasons why SP2010 does not render files in browser, this change was made due to security reasons in SharePoint 2010. PDF included.

After considering the possible dangers you Could enable permissive mode, but that works for all file types. Instead it is much less of a security hole to just enable pdf as allowed inline mime types for the web application:


$webapp = Get-SPWebApplication <your webapp url> 
$webapp.AllowedInlineDownloadedMimeTypes.Add(“application/pdf”)
$webapp.Update()

Hope this helps.......

Tuesday, 28 October 2014

Delete all attachments from custom SharePoint list without code

There are some times when you asked to delete all attachments from a SharePoint list. SharePoint itself has given simple solution for this which will not require knowledge about coding or PowerShell or any difficult and time consuming techniques.

Few clicks and your work is done.

  1. Open your list
  2. Go to list settings
  3. Advanced Settings
  4. In Attachments option select radio button "Disabled" and click OK
  5. It will ask you for confirmation
  6. And once you confirmed, it will delete all attachments from SharePoint list
Done....

Hope this helps...


Tuesday, 2 September 2014

Adding user in SharePoint group programmatically

Below is the code to add user in SharePoint group programmatically:


 using (SPSite site = new SPSite(Respective Site URL))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    try
                    {
                        SPUser requiredUser = web.EnsureUser("domainname\\username");

                        if (requiredUser != null)
                        {
                            SPGroup requiredGroup = web.Groups["groupName"];
                            if (requiredGroup != null)
                                requiredGroup.AddUser(requiredUser);
                        }
                   
                    }
                    catch (Exception ex)
                    {
                     
                    }                 
                }
            }

Monday, 1 September 2014

Error occurred in deployment step 'Retract Solution': Object reference not set to an instance of an object.

Today while deploying a custom solution on our development server using Visual Studio 2012, I received below error in Visual Studio: 
"Error occurred in deployment step 'Retract Solution': Object reference not set to an instance of an object."

This was working well till day before and suddenly it started to throw same error again and again.
Then I went to retract same solution through Central Administration, and it shown me actual error that was happening.

The SharePoint_Config log file got full. After shrinking the log file, solution got deployed without any error.

Related Posts Plugin for WordPress, Blogger...