Search This Blog

Wednesday, December 21, 2016

How to pass value from SharePoint modal dialog to Parent window

We can pass the value from SharePoint Modal dialog to its parent window.

After a long search i found the below solution:

Parent Window:

function OpenPopUp() {
                var siteCollectionURL = _spPageContextInfo.siteAbsoluteUrl;
                var options = {
                    url: siteCollectionURL + "/Sitepages/PopUpView.aspx",
                    dialogReturnValueCallback: CloseCallback,
                    height: 900,
                    width: 800
                };
                SP.UI.ModalDialog.showModalDialog(options);
                return false;
            }

function CloseCallback(result, target) {
              ///Value given at Popup window will come as target value
                alert(target);

            }

PopUp window:


function Successclosepopup() {
              var returnValue = "PopUp Successfully Closed";
              SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, returnValue);

            }

Hope this may help you.

Thanks.,


Monday, May 30, 2016

BUSINESS CONNECTIVITY SERVICES in SharePoint 2013

What is BCS?

The short answer is pretty simple – BCS enables you to connect to ‘other’ data sources outside of SharePoint and literally treat them as a SharePoint List.
With BCS, you can bring information into SharePoint from a variety sources. For example, you can bring data from an external SQL Server database, a traditional web service, a WCF service, proprietary systems, and OData services.

How to Implement with SQL External Data Source:

1. Open SharePoint Designer with the required URL:


2. Select the External Types from left menu and click on External Content type from ribbon menu


3. Change the name of External Content type information and select the Item type.


4. Select Click here to discover external data source and define operations.


5. Click Add connection and Choose External Data Source Type:


6. Here we selected SQL server, now we need to provide the Server credentials:


   Once we provided the server and DB details then our DB will be enabled here. As we can see i            have connected my Test DB for BCS.

7. Under our DB we can select any table and we can create operations for that [articular table:
    Here we can create any operation for that table. Here i am creating all operation for that student table

8. Next we will see the Operation properties:



9. Once the operations are created then we need to create an external list for that particular Table:


    Here select the BCS name and click ok.


Give a name for the external list. Once the list is created then we can see that list in our URL under site contents.
If you open that list you may see like this:


10. Open central admin. Under application management click on Manage Service Applications


   Under that we can see Business Data Connectivity Service if you click on that we can see our BCS 


   From that click our BCS and Select on Set permissios:


 There give permissions to corresponding users:


After that it will work. If don't then set Meta data store permissions same as set permission and give the required permissions to the corresponding users then it will surely work.

You can add items in that list which will reflect in that table. 



Thank you...

Thursday, April 7, 2016

Working With SharePoint 2013 APP - Three SharePoint 2013 App Deployment Models

What are the Three SharePoint 2013 App Deployment Models?

  • SharePoint-hosted
  • Self-Hosted
  • Automatically Provisioned Azure Web Application


SharePoint Hosted Apps:

When the app is hosted in SharePoint itself, the code is only in HTML and JavaScript and is hosted by SharePoint.A SharePoint-hosted app may provision basic resources into its app web such as HTML/CSS/JS files, site column/content type/list definitions, etc. 
Under no circumstances can server-side code run within a SharePoint-hosted app.

In the SharePoint-hosted deployment type model, a new isolated subweb known as app web is created under the parent site called the host web,for hosting app. The app web keeps all the app content such as lists, workflows, pages, out-of-webparts and so on. 
The app code runs in the client browser which can use only HTML and JavaScript with CSOM / REST API and not any server side code.

Provider Host Apps:

In a provider-hosted app, you are responsible for the infrastructure (again, external to SharePoint) where your app runs. You have lots of flexibility in the sense that you can run full-blown server side code and even take advantage of frameworks like ASP.NET MVC 
(or even use Java, PHP, or other non-Microsoft technologies as well), but you are also responsible for things like tenant isolation.



You or your app purchaser’s IT department must host a provider-hosted app on a dedicated server or third-party hosting service. Depending on your choice, these apps run either on your server or in the cloud. A provider-hosted app can also include SharePoint components that run in SharePoint, so it can be mixed in its hosting

The Provider-hosted deployment model is almost same as Auto-hosted model, the only difference is that the app code resides in an external domain or server i.e. your own hosting environment which may not be necessarily be windows-based. The app code can be written in any programming language and technology like PHP, .NET or Java. 
In this scenario, SharePoint acts only as launching pad for the external app. 

Auto-Hosted App:

In this cloud model, though the app is developed for SharePoint but the app code resides outside of the SharePoint on Microsoft Windows Azure in the background, 
which can also have access to Microsoft SQL Azure database for managing data. The app is automatically deployed to Windows Azure and SharePoint creates a cloud-hosted app on your behalf. Auto-hosted model is supported on SharePoint Online only unlike the other deployment models.



Working With SharePoint 2013 APP - Introduction

Apps for SharePoint or SharePoint Add-ins:

First, a quick background: 

SharePoint 2010 introduced the sandboxed concept, the predecessor to SharePoint Apps, but it offered limited access for developers at the site-collection level. It had many issues and had to work under several code access security (CAS) policies. What grew out of that was the need for a new concept that would allow developers to become more productive, 
efficient and have more freedom and, thus, SharePoint Apps.

One of the important things to note is that a SharePoint App creates a sub-site of the site where the app is installed and supports creating lists, defining properties and so on.

Microsoft set out to create an extensibility point in SharePoint 2013 that would allow customers to build their own solutions for SharePoint without hurting the hosted model whenever a customer’s code was found to be ‘executionally challenged’. They came up with a model called a SharePoint App, which is simply a solution with no SharePoint server side code.

Here are some important notes to be made on SharePoint Apps when compared with farm solutions:

1. App code never runs within the SharePoint host environment.
2. Apps have two scopes: They can work within the scope of a SharePoint site, as well as with a special SharePoint site        called the App Catalog.
3. No down time is required for the whole environment when an app is being upgraded.





Default Sharepoint URL

(Remember for SharePoint 2013, 2016 you might want to add “15”, “16” respectively after “/_layouts/” but if you don’t SharePoint will take care of that for you) .. Also some of these are turned off on Office 365 SharePoint online.


Site collection level recycle bin:
      /_layouts/15/AdminRecycleBin.aspx

Site level recycle bin (Added by Steve Stewart):
      /_layouts/RecycleBin.aspx

Recreate default site sp groups (Added by Neal Bongers):
      _layouts/15/permsetup.aspx

Load document tab initial (Added by Dominik Gempeler)
      ?InitialTabId=Ribbon.Document

Delete user from Site collection (on-premises) (Added by SamDavid):
       /_layouts/15/people.aspx?MembershipGroupId=0

Display list in grid view. ‘True’ is case sensitive (Added by Antoine L.):
      ?ShowInGrid=True

Quick Launch settings page (Added by Ishani M.):
       /_layouts/quiklnch.aspx

Navigation Settings page (Added by Abdur Raheem):
        /_layouts/15/AreaNavigationSettings.aspx

Sandboxed Solution Gallery:
        /_catalogs/solutions/Forms/AllItems.aspx

Workflow history hidden list:
        /lists/Workflow History

Filter toolbar for Lists and libraries (Added by Asimaili):
?Filter=1
Site usage page (Added by @Dnyag):
       /_layouts/usage.aspx

Site content and structure  page (Added by @Dnyag):
      /_layouts/sitemanager.aspx

Site settings page (Added by Aowworld):
      /_layouts/settings.aspx

View all site content page (Site content) (Added by Aowworld):
      /_layouts/viewlsts.aspx

Manage site collection features – CASE SENSITIVE –  (Added by Vardhaman):
      /_layouts/ManageFeatures.aspx?Scope=Site

Manage site features (Added by Vardhaman):
      /_layouts/ManageFeatures.aspx

 Get the version of the SharePoint server (Patch level) (Added by: John Liu):
      /_vti_pvt/Service.cnf

Web Part Maintenance Page (Added by: Ricky):
?Contents=1

Show Page in Dialog View (Added by:Ricky):
?isdlg=1

Application page for registering SharePoint apps
     /_layouts/15/appregnew.aspx

Save Site as a template
     /_layouts/savetmpl.aspx

Sign in as a different user
     /_layouts/closeConnection.aspx?loginasanotheruser=true

Enable SharePoint designer
      /_layouts/SharePointDesignerSettings.aspx

Welcome Page (Default page settings)
      /_layouts/AreaWelcomePage.aspx

Change Site Master Page
      /_layouts/ChangeSiteMasterPage.aspx

Page Layouts and Site Templates
      /_Layouts/AreaTemplateSettings.aspx

Master Pages library
      /_catalogs/masterpage/Forms/AllItems.aspx

Quick Deploy List
Quick%20Deploy%20Items/AllItems.aspx

Open Page in Edit Mode
?ToolPaneView=2

Taxonomy Hidden List (MMS)
      Lists/TaxonomyHiddenList/AllItems.aspx

User Information List:
 _catalogs/users
_catalogs/users/simple.aspx

Force displaying the user profile in the site
collection:
      /_layouts/userdisp.aspx?id={UserID}&Force=True

Site hierarchy page (lists of sub sites) – (Added by community contributions)
     /_layouts/vsubwebs.aspx
     /_layouts/1033/vsubwebs.aspx

Wednesday, March 30, 2016

How to enable custom login page in SharePoint 2013

1. Enable anonymous for that web application

    1.1 Choose your web application
   

    1.2 Choose the Authentication Providers from top menu

  

    1.3 From that check the Enable anonymous access
2. Enable Forms Based Authentication (FBA)
   ASP.NET Membership provider name - wmembership
   ASP.NET Role manager name - wrolemanager
 

3. Change the Custom login page url in you webconfig. In authentication tab change the default URL
   <forms loginUrl="/_layouts/15/CustomLogin/Login.aspx" domain="domain.com" />
 
4. Add the following tag in Security token config file

<system.web>
    <membership defaultProvider="wmembership">
      <providers>
        <add name="wmembership" type="Nauplius.ADLDS.Provider.LdapMembership, Nauplius.ADLDS.Provider.2013, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e1247d213b5ddc40" server="trigchn.com" port="389" useSSL="false" userDNAttribute="distinguishedName" userNameAttribute="sAMAccountName" userContainer="DC=trigchn,DC=com" userObjectClass="person" userFilter="(ObjectClass=person)" scope="Subtree" otherRequiredUserAttributes="sn,givenname,cn" />
      </providers>
    </membership>
    <roleManager defaultProvider="wrolemanager" enabled="true" cacheRolesInCookie="true" cookieName=".PeopleDCRole">
      <providers>
        <add name="wrolemanager" type="Nauplius.ADLDS.Provider.LdapMembership, Nauplius.ADLDS.Provider.2013, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e1247d213b5ddc40" server="trigchn.com" port="389" useSSL="false" groupContainer="DC=trigchn,DC=com" groupNameAttribute="cn" groupNameAlternateSearchAttribute="samAccountName" groupMemberAttribute="member" userNameAttribute="sAMAccountName" dnAttribute="distinguishedName" groupFilter="((ObjectClass=group)" userFilter="((ObjectClass=person)" scope="Subtree" />
      </providers>
    </roleManager>
  </system.web>

5. Now do an IISREST and refresh your application. You can see your custom login page.
  

Wednesday, March 23, 2016

Creating SharePoint Timer Job

Timer Job:

Timer Job is a background process that are run by SharePoint. It is a periodically executed task inside SharePoint Server. It provides us a task execution environment.


Default Timer Jobs inside SharePoint:

There are many timer jobs inside SharePoint which do internal tasks like:
    • Send emails
    • Validate sites
    • Delete unused sites
    • Health analysis
    • Product versioning
    • Diagnostics
These tasks will having execution periods like:
    • Minute
    • Hour
    • Day
    • Week
    • Month

1) Create an empty SharePoint project and add an class file in that project.
    Derive CustomTimerJob Class from SPJobDefinition which comes from 
    Microsoft.SharePoint.Administration.dll

Example:
    class TestTimerJob : SPJobDefinition
    {
     }

2) Add the three Constructors of the derived class : When ever we create the object of CustomTimerJob  class, corresponding constructor will execute.
   
Example:  
  public TestTimerJob() : base()
        {
        }

   public TestTimerJob(string sJobName, SPService service, SPServer server, SPJobLockType targetType)
            : base(sJobName, service, server, targetType)
        {
        }

   public TestTimerJob (string sJobName, SPWebApplication webApplication)
            : base(sJobName, webApplication, null, SPJobLockType.ContentDatabase)
        {
            this.Title = "Test Time Job";
        }

3) Override the Execute method: When ever the timer job start running then the code inside the Execute method will run.

Example: 


public override void Execute(Guid targetInstanceId)
        {
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite Osite = new SPSite(SPContext.Current.Site.ID))
                    {
                        using (SPWeb Oweb = Osite.OpenWeb())
                        {
                            SPList TestTasksList = Oweb.Lists.TryGetList("TestTasksList ");                          
                            SPListItemCollection TestTasksListCol = TestTasksList.GetItems();
                            foreach(SPListItem Oitem in TestTasksListCol)
                           {       
                                 Oitem["Title"]="TimerJob";
                                  Oitem.Update();   
                           }
                        }
                    }
                });
            }
            catch (Exception)
            {
                throw;
            }
        }


4) We need to create a Feature and Feature Receiver so on activation of this feature we are going the add our timer job to SharePoint farm.
    1. Create a new feature and set its scope as Site
    2. Add an event receiver by right clicking that feature. 
    3. And also create a name for your timer job;

const string JOB_NAME = "Test TimerJob";

       In that feature include the following code for Feature activated and Feature Deactivating

Feature Activated:
 public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPSite site = properties.Feature.Parent as SPSite;

            foreach (SPJobDefinition job in site.WebApplication.JobDefinitions)
            {
                if (job.Name == JOB_NAME)
                    job.Delete();
            }
            OverdueTasksTimerJob listLoggerJob = new OverdueTasksTimerJob(JOB_NAME, site.WebApplication);
            //SPMinuteSchedule schedule = new SPMinuteSchedule();
            SPDailySchedule schedule = new SPDailySchedule();
            schedule.BeginSecond = 0;
            schedule.EndSecond = 59;
            //schedule.Interval = 5;
            listLoggerJob.Schedule = schedule;
            listLoggerJob.Update();
        }

Feature Deactivated:
       public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPSite site = properties.Feature.Parent as SPSite;

            // Delete the timer job
            foreach (SPJobDefinition job in site.WebApplication.JobDefinitions)
            {
                if (job.Name == JOB_NAME)
                    job.Delete();
            }
        }

5) Next deploy you solution and check you timer job is comes under Job definitions in Monitoring option in central admin. If it doesn't come then activate the feature manually using Power shell command.

Example:
Enable-SPFeature FeatureFolderName -Url http://server/site/subsite

Note: you can get the Feature name from the following path:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\FEATURES


    
   
























Restricting Custom People Picker to only one Sharepoint group programatically

Refer the following script files in your page,     <!-- For People Picker -->     <script type="text/javascript" src...