Wednesday, July 31, 2013

MVC4 Session @ SL Air Force

I have hosted a MVC4 introduction and basic development session for Sri Lanka Navy (Head Quarters) behalf of Microsoft Sri Lanka. Audience was pretty good and we had  a more than one our questions and answer session

Date : 31 Jul 2013

Attendance : 15 Members

Friday, July 26, 2013

Single Reference JavaScript Pattern for SharePoint 2013 App Development and Web Development (SRJ Pattern by Melick)

I have tried many different ways to properly organized JavaScript in my Developments. When I'm developing I have faced following issues.

  • Each and every place we need to include script files
  • IF one place change we need to change all the pages for references
  • Assume we need to update JQuery  version then we need to change all pages which refers scripts.

Thus i thought to work on my pattern with the help of JavaScript Loader to overcome this situation. I have used Head.js to dynamically load JavaScript's. There are few other JavaScript loaders such as

I have chosen Head.js because of performance and simplicity you can develop this pattern to work with any JavaScript loader. Head.js supports other css declaration and media queries as well. This pattern can be extended support css loading as well.

This is very simple pattern. In here you need to only refer one script in a page and It will take care of loading other scripts for you. So I'm sure it is saving your development time as well as script maintenance time.

How to Use the Pattern in Nutshell

image

When every thing is prepared you need to Only refer one script in your pages.

   If you want to write a code by loading common scripts then you need to say like

<script src="Scripts/ScriptBase.js"></script>
<script>
    BaseReady(function () {
        // Add you code Here
    });
</script>

   If you want to write a code after MyScript.js is loaded then you need to say like



<script src="Scripts/ScriptBase.js" ></script>
<script>
    BaseReady(function () {
        IncludeScript(js.app);
        ScriptReady(function () {
            // Write Your code here
        });
    });
</script>

   If you want to write a code after MyScript.js,Second.js is loaded  then you need to say like



<script src="Scripts/ScriptBase.js" ></script>
 
<script>
    BaseReady(function () {
        //app: '/Js/MyScript.js'
        IncludeScript(js.app); 
        // '/Js/Second.js' 
        IncludeScript(js.second);
        ScriptReady(function () {
           // Write your code here
        });
    });
</script>

With jQuery



<script src="Scripts/ScriptBase.js" ></script>
<script>
    BaseReady(function () {
        IncludeScript(js.app);
        ScriptReady(function () {
            $(document).ready(function () {
                // With jQuery
            });
        });
    });
</script>

How to Prepare the Pattern



  • You need to copy ScriptBase.js to your JavaScript folder. (My file is under Script Folder)
  • Then You Need to Download Head.Js and put it in to the same library. (You can take Head.min.js since it is minified to greater performance)
  • Open the ScriptBase.js


image



  • If you want any absolute URL you can put it in serverUrl. (But normally we wont)


image



  • BaseUrl is the Script Path related to Project Main hierarchy. For an example following scenario we can mentioned baseUrl as /Scripts


image


image



  • Then You can specify all the scripts you need in the project.There are three types of script references so far i found. You can extend it to any other ways if you want.

    • Scripts reside under BaseUrl
    • Scripts directly reference using absolute Url
    • Dynamically deciding script Url (Ex:- Based on Query String)


image




var js =
{
  Head: '/head.js', // Original Path /Scripts/head.js
  jquery: '/jquery-2.0.3.js', // Original Path /Scripts/jquery-2.0.3.js
  app: '/Js/MyScript.js',    // Original Path /Scripts/Js/MyScript.js
  second: '/Js/Second.js',  // Original Path /Scripts/Js/Second.js
};



    • Scripts directly reference using absolute Url

      • You can directly put the Url


      var js =
      {
        lst: 'http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js'
      };

    • Dynamically deciding script Url (Ex:- Based on Query String)


      • In SharePoint development we need to refer JavaScript based on  URL parameter. For an example SPHostUrl and SPAppWebUrl. In here we can Specify the prefix of the Url with #tag (Ex- #SPHostUrl) and change the GetUrl() method to match the requirement.


image




  • After that if you want some scripts to load in every page (Ex:- JQuery) you need to add it to CommonScripts() Method. When adding scripts you can follow the below pattern. You can give a js.yourscript name.

image


Then you can use it for your project. (Refer How to Use the Pattern in Nutshell )

Thursday, July 25, 2013

SharePoint Status Notifications and Pop Ups SharePoint 2013 Apps

First we need to refer following SharePoint related JavaScript and jQuery

<script type="text/javascript" src="YourLocation/Scripts/jquery-2.0.1.min.js"></script>
<script type="text/javascript" src="/_layouts/15/MicrosoftAjax.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>

After That You can



<script language="javascript" type="text/javascript">
    
    // This will automatically disappear after some time
    SP.UI.Notify.addNotification('Processing...', false);
 
    // This will remove after you click or removed by a code
    SP.UI.Notify.addNotification('Processing...', true);
 
</script>

image



<script language="javascript" type="text/javascript">
// Set the status and get the reference
var status = SP.UI.Status.addStatus("Info:", "Processed");
// Add a Color
SP.UI.Status.setStatusPriColor(status, 'blue');
//Set Time out time , If not It will be there until we click
setTimeout(function () { SP.UI.Status.removeStatus(status); },3000);
</script>

image


Few other Methods we can use



<script language="javascript" type="text/javascript">
    
    // Remove Specific status
    SP.UI.Status.removeStatus(status);
 
    // Remove All status
    SP.UI.Status.removeAllStatus(true);
 
</script>

Thursday, July 11, 2013

Step by Step Approach to Create a Visual Studio SharePoint Workflow (Sequential)

First we need to install and Configure Workflow Manger. You can install it using Web Platform Installer

image

You can find complete guide here (Prabath’s Blog).

image

image

image 

image

select the options that you need to run the workflow

  • Manual
  • Item Created
  • Item Changed

As a sample WF I’m going to get the “Age” Column in the item and Write it to log and update a column using a message.

image

Since we need to look the Age Column, i added the LookUpSPListItem to the sequence.  In the LookUpSPListItem you need to set properties to currentitem and currentlist as well as valuable you need to retrieve properties (You can change these on right side property window).

Then by clicking get properties VS generates a GetDynamicValueProperties action. In there you need to select the variable as the Source and specify properties you need to retrieve.

 image

Then drag and drop a WriteToHistory Action to the sequence. here you can go to properties and specify the message you need to log to history.

Then you can insert UpdateListItem with the Property and variable you want.

And ultimately you can deploy the workflow to your server.

image

I will put another set of posts by saying how each and every workflow actions works. This post is only touching overall process (steps) to deploy a workflow. :D

Wednesday, July 10, 2013

SharePoint 2013 Visual Studio is not going deploying and remain same as previous version.

i created a visual studio workflow and first time successfully deployed it to SharePoint server and it worked fine. But after i modified it; it didn't work.So i found visual studio cashes it in a vssphost5.exe process.

image    

end the process and deployed it again. and it worked :)  

Enhanced Community Features @ SharePoint Forum

unnamed

Monday, July 8, 2013

Error 2 Error occurred in deployment step 'Activate Features': System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.WorkflowServices.WorkflowSubscriptionStorageEventReceiver.ItemUpdating(SPItemEventProperties properties) 0 0

This error occurred when i try to deploy a visual studio workflow to the SharePoint. By checking the  ULS i got the following error as well

Can't find WorkflowServiceProxy or its service application proxy type name is null

To overcome this error we need to install and configure  the workflow manager.

image

Reference: http://prabathf.blogspot.com/2013/02/installing-and-configuring-workflow-for.html

Thursday, July 4, 2013

Change the IE Compatibility Mode manually

We can set HTML rendering mode using Meta Tag.

<meta http-equiv="X-UA-Compatible" content="IE=5" />

This is set compatible mode to IE-5, like wise there are few modes we can set using a meta tag.



content="IE=5" - force to render in “Quirks” mode.

content="IE=7" - forces to render in IE 7 Strict mode.

content="IE=EmulateIE7" - use !DOCTYPE declaration to detect rendering mode

content="IE=8" -   forces to render Internet Explorer Standards mode.

content="IE=EmulateIE8" - use !DOCTYPE declaration to detect rendering mode

content="edge" - use most recent mode


Reference http://hsivonen.iki.fi/doctype/


We can use  Web Config to alter the page rendering mode



<httpProtocol>
   <customHeaders>
     <remove name="X-UA-Compatible"/>
     <add name="X-UA-Compatible" value="IE=edge"/>
   </customHeaders>
</httpProtocol>

Wednesday, July 3, 2013

Configure Power View (Reporting service Features) on existing SharePoint 2013 Farm With BI Features (Small Farm – APP & DB)

Configuration Summary

  • Install SQL Server 2012 SP1 (SQLServer2012SP1-FullSlipstream-ENU-x64)
  • Uninstall Report Services - Native If you have installed it
  • Install Reporting Services – SharePoint & Reporting Services Add-In for SharePoint Product
  • Install Analysis Services In Tabular Mode and Data Tools
  • Install SharePoint Reporting Service
  • Install and Configure Power Pivot for SharePoint
  • Configure Performance Point Services
  • Configure Reporting Services
  • Check SharePoint Power Pivot Integration

Install SQL Server 2012 SP1 CTP3

First you need need at least SQL Server 2012 SP1 CTP 3 installed in your farm.  If not you can download and install it from here

Better if you can restart the machine after installation.

Uninstall Report Services – Native

If You have already installed Reporting services Native go to Control Panel and Uninstall SQL Server and remove the Reporting Services – Native Feature.

image

Install Reporting Services – SharePoint & Reporting Services Add-In for SharePoint Product

If you are not installed Reporting Services – SharePoint and Reporting services Add –ins

you need to run SQL Server 2012 and select Add features to an existing instance of SQL Server 2012

 image

Select Reporting Services – SharePoint and Reporting services Add –ins for SharePoint Products and Proceed

 image

Then install as Reporting Services SharePoint Integrated Mode

image

Install Analysis Services In Tabular Mode and Data Tools

If you have already installed the Analysis services uninstall in and install it in Tabular Mode.

image

image

after the installation restart the machine . (This is not mandatory)

Install SharePoint Reporting Service

Open the SharePoint Management Shell and run following commands If every thing is fine it will return no errors.

  • Install-SPRSService
  • Install-SPRSServiceProxy

image 

Note: If you come across this error you need to install SQL Server 2012 SP1 CTP3 again and restart the machine again.

Install-SPRSService : The term 'Install-SPRSService' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the

Install and Configure Power Pivot for SharePoint

Download PoverPivot for SharePoint.  (http://www.microsoft.com/en-us/download/confirmation.aspx?id=35577)

Run the setup as administrator.

image

image

After the installation you need to run the PowerPivot Configuration as a admin.

 image

image

image

Validate and run the configuration.

image

Configure Performance Point Services

Go to Central Admin and go to Manage service applications and create Performance Point Service Application.

image

When creating the Service Application make sure you inserted the Unattended Service Account.

image

ultimately check PerformancePoint Service is up and running.

image

Configure Reporting Services

Go to Central Admin and go to Manage service applications and create Reporting Service Application.

image

When you are creating make relevant web associations to  your web applications.

image

When service application created navigate to Provision Subscriptions and Alerts

image

and enter spadmin account and make in as Windows Credentials. (This account should have sysadmin permission in the Database )

image

Then make sure SQL server Agent is up and running

image

Then download the Script and execute the SQL.

image

and finally make sure SQL Server Reporting Services is running.

image

Now You are almost over.

Now you need to go to site collection and activate features

Site Collection Features

Performance Point Site Collection Feature

PowerPivot Feature Integration for Site Collections

Site Features

PerformancePoint Site Feature

SharePoint Server Enterprise site feature

Monday, July 1, 2013

Could not load type ‘Microsoft.AnalysisServices.SharePoint.Integration.ReportGalleryView’

I came across this error when i activate the the  PowerPivot Feature Integration for Site Collections in the site collection and accessing the PowerPivot Gallery in the site.

So I went to central admin and go to  Mange farm solutions

image

image

and Deploy the powerpivotwebapplicationsolution.wsp to what ever the web application you want.

image