Friday, August 17, 2012

Creating Share Point 2013 Apps on O365 Preview Using NAPA

While exploring on share point 2013 last week, I surprised with lot new features in 2013.Its definitely making our life easy in case of collaboration, search and document management.
I tried to create one app on O365 from my trial developer account and like to share with you people to have its little idea.
Just go through the below steps and check how easy it is to develop App on O365. It provides the NAPA development tool for developing the O365 app.Before starting there are some prerequisite that has to be completed.

You need to register for O365 developer site account.
Required IE9 running on your computer

Once you done with above steps go through below given steps to create you first app.

1. Create development site collection from your O365 account.
  Go to to SP admin center
  Click on site collection
  Create new private site collection using development site template. Complete the necessary steps like allocating space url and name of site collection.

Copy the newly created site collection and put it in new browser window. The site looks like this


Click on site Gear icon and select Add an App


The next step is to go to the home page of this site,click on site content then click on NAPA app and select app for share point .Give name for app. Here its SuryakantSharepointApp1.



After crating the app now it take you to its default.aspx page. Write some code in placeholdermain control


Now click on Apps.js file and add some java script/jquery function.  



Once done with all coding part now its time to run your app and that you can do from bottom left corner action buttons.Click Run button to run your app.


After clicking on run it goes through the uninstall,install and deploy and launch stages.



And here is your first O365 App.chase...!






Monday, August 13, 2012

Creating BCS connection with detail steps


Creating BCS connection is little tricky part and if you miss some steps then it takes more time to do it. It’s just configuration work but still people are not able to do it because there are some small steps needs to be done like setting permissions configuring secure state service etc. and if those are missing while doing it then  it’s becoming critical for them. Here I have given detail steps to configure the BCS connection and creating external list to bring external data in share point and I explained here each step required while doing this process.
May be you guys will help it for doing the BCS connection. Still you find any difficulty feel free to contact me on my mail.
Before start creating BCS connection from SP designer we must have to create secure target application from central admin
Open CA and then
Central Admin> Application Management > Manage Service Applications > Secure Store Service Application > Click on New button from ribbon.
Click on Next then below screen occurs add user id and password details

Click next and add administrator for this secure state application


Next step is to set the credentials for this application. Click on arrow icon of application id and it shows the menu. Select set credentials.
After clicking the set credentials its shows below screen for adding the credentials details. Add credentials and hit OK.
Now the configuration part one is done. We will have to do one more configuration that we will see in next steps. Its now time to start cresting the ECT(External Content Type) so start SP designer and open your site and click on external content type.

Add the connection name display name, list type and click on external data source link to make the connection. Its shows below screen now click on Add Connection and it gives you the three types of data source as we are connection with SQL server so select SQL type from it
After selecting the data source now its time to provide the connection details so add server name, database name. And select middle option connects with impersonation identity option.
After adding server details insert the credentials details in below window and click OK.
Now connection is added and it will display the tables from the database. Expand the required table and select the type of the operation you want to do with it.


Add configuration as per you requirement and go on clinking Next still Finish.




After doing all the table settings. Click on save to save the connection.
Now its time to create the external list from external list template. So go to create list option select the ECT template and create the list.


After creating the list when you come to the list all item view you will get below error
And this is due to credentials. So set the credentials for BCS Connection from CA.





Once the credentials are added just refresh the screen and you will get your data from related table.




















































Saturday, August 4, 2012

Creating and deploying the timer jobs in share point 2010


When there is any activity wants to happen automatically in share point then there is one quick solution and that is Timer job.Timer job runs in a specific Windows service for SharePoint Server.Its very easy to create the timer job and deploy to share point server.Timer job can be set from seconds to years period.Timer job contains a definition of the service to run and specifies how frequently the service is started. SharePoint timer service runs the the timer job.This feature is debugged uisng OWSTimer process.

Below is one example which gives idea of creating and deploying the timer job. It definately help you in enhansing your knoweldgebase.

Steps for creating the timer job.

1. Create new project from visual studio with share point template




2.Once the project is selected now its time to to set the SP server url. Since the timer job can not be deployed as sandbox solutions so select the farm solution for deployment.




3. Open the solution explorer and right click on project name and add the new item and that is class.



4. After adding the class now add the feature because the timer is deployed as feature to share point server. Right click on feature and select add feature and sets its scope.



5. Add the event receiver by right clicking on the feature.

6. Once all the required files are added in solution now its time to play with code. So open the class which we added in step 3 and add code as below.

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

namespace TestTimerJob
{
    public class TestTimerJob : SPJobDefinition
    {
        public TestTimerJob()

            : base()
        {

        }

        public TestTimerJob(string jobName, SPService service, SPServer server, SPJobLockType targetType)

            : base(jobName, service, server, targetType)
        {

        }

        public TestTimerJob(string jobName, SPWebApplication webApplication)

            : base(jobName, webApplication, null, SPJobLockType.ContentDatabase)
        {

            this.Title = "Test Timer Job";

        }
        public override void Execute(Guid contentDbId)
        {

            SPSite oSPSite = new SPSite("http://MySharepointTestServer");
            SPWeb oSPWeb = oSPSite.RootWeb;
            oSPWeb.AllowUnsafeUpdates = true;

            SPList testList = oSPWeb.Lists["TestList"];
            SPListItem newTaskItem = testList.Items.Add();
            newTaskItem["Title"] = "NewItem";
            newTaskItem.Update();

            oSPWeb.AllowUnsafeUpdates = false;
        }
    }
}


6.  Now add the code for event receiver  class for its scheduler logic, activation and deactivation method as like below.

using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Administration;

namespace Test.Features.Feature1
{
    ///
    /// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
    ///
    ///
    /// The GUID attached to this class may be used during packaging and should not be modified.
    ///

    [Guid("1d48fa2f-edce-428c-bfea-bb9fc473f9ca")]
    public class Feature1EventReceiver : SPFeatureReceiver
    {
        // Uncomment the method below to handle the event raised after a feature has been activated.
        const string List_JOB_NAME = "TestListTimer";
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPSite site = properties.Feature.Parent as SPSite;

            // make sure the job isn't already registered

            foreach (SPJobDefinition job in site.WebApplication.JobDefinitions)
            {

                if (job.Name == List_JOB_NAME)

                    job.Delete();

            }
            // install the job

            TestTimerJob listLoggerJob = new TestTimerJob(List_JOB_NAME, site.WebApplication);

            SPMinuteSchedule schedule = new SPMinuteSchedule();
            //SPHourlySchedule schedule1 = new SPHourlySchedule();
            //SPDailySchedule sc = new SPDailySchedule();
            //SPYearlySchedule scy = new SPYearlySchedule();
            
        

            schedule.BeginSecond = 0;

            schedule.EndSecond = 59;

            schedule.Interval = 5;

            listLoggerJob.Schedule = schedule;

            listLoggerJob.Update();
        }


        // Uncomment the method below to handle the event raised before a feature is deactivated.

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

            // delete the job

            foreach (SPJobDefinition job in site.WebApplication.JobDefinitions)
            {

                if (job.Name == List_JOB_NAME)

                    job.Delete();

            }
        }


        // Uncomment the method below to handle the event raised after a feature has been installed.

        //public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        //{
        //}


        // Uncomment the method below to handle the event raised before a feature is uninstalled.

        //public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        //{
        //}

        // Uncomment the method below to handle the event raised when a feature is upgradin8. g.

        //public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary parameters)
        //{
        //}
    }
}



7. Build the solution and deploy to the server.


8. The above deployment can be done on VM or your development server but if you have to deploy it to the production then you have to use STSADM or PoweShell command.

shell command” - Enable-SPFeature -Identity “FeatureName” -Url “https://Servername″

STSADM  - stsadm -o activatefeature -fileName MyTestTimer\TestTimerFeature.xml -url  -force

                  stsadm -o deactivatefeature -fileName MyTestTimer\TestTimerFeature.xml -url   -force