Pages

Sunday, November 17, 2013

Setting up Welcome Page for a SharePoint Site

Some SharePoint objects needs an instance to work perfectly, and below line of code will not work:-
 SPSite site = new SPSite("http://a2zdinesh:1010/sites/InternetSite/");
SPWeb web = site.OpenWeb();
web.RootFolder.WelcomePage=”SitePages/Dashboard.aspx”;
web.RootFolder.Update(); 

After trying hard came to know that with above way we cannot set the Welcome page for a non-publishing site. Exact reason is not well kept in any MSDN and to set we need to use the SPFolder Object. Below is the sample code of it,

SPSite site = new SPSite("http://a2zdinesh:1010/sites/InternetSite/");
SPWeb web = site.OpenWeb();
SPFolder folder = web.RootFolder;
folder.WelcomePage = "SitePages/Dashboard.aspx";
folder.Update();

Will post you if I get any..:-) 
 

Sunday, November 3, 2013

KPI's in WSS/SharePoint Foundation using Dataview Webpart

Business Problem:-
A Small or Medium Scale industries who can't afford to buy the MOSS 2007 or SP 2010/2013, and having the environment of WSS [Any version] or SharePoint Foundation [Which is very low Cost] requires the Key Performance Indicators or the better Look and feel or the specified functionality.

Technical Issue:-

If the users use the MOSS 2007 or SP 2010/2013, the above problem is solved with OOB features. If he wants on WSS [Any Version] or on SharePoint foundation, we will be not having the Content Query webpart or KPI Webparts. Then we can solve the issue by introducing the Data view Webpart. [With Workaround on this OOB Webpart]

Steps to follow:-
1. Create a New Page in the SharePoint Designer.

2. Click on Insert -> SharePoint Controls -> Data View as shown below.
3. After placing it, you will observe as below, where the Webpart Zone will be placed in Page and in the right section you can see the Data Source Library

 

4. Now select the required Data Source like list or library etc., Let us suppose select One List like below screen.
                                           

5. After selecting List you will get the Data Source Details as below. Select the required fields to view and click on the Insert Selected Fields -> Mulitple Item View
                     

6. You will observe the below screen, where in the code you can see the XSL Stylesheet. Hope now you all got my next steps if you are aware of devleoping Content Query Webpart with XSL Styling.


Create KPIs
7. Now it’s time to create some fancy indicators to show if goal is reached. To do so you will need to open your page in SharePoint designer code view.

8. Add an additional th tag. It will create one additional column to display our KPI status icon.

9. Now we will need to add actual code to display the image. Look for the following code:


10. The code above displays the value of the Value column of our list. Paste the following code below it.
<td class="ms-vb">
<img alt="KPI Status Icon">
<xsl:attribute name="src">
<xsl:choose>
<xsl:when test="number(@Forecast_x0020_Cost) &lt; number(@Cost)">/_layouts/images/statusAmber.png</xsl:when>
<xsl:otherwise>/_layouts/images/statusRed.png</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</img>
</td>
Here in the above code place required logic.

11. You will observe as below. [Don’t get confused as below is one which I added two Columns as Indicators]
 

12. Now browse the Page.

SPMetal - SharePoint 2010 & 2013

As we know SP 2010 has introduced a way where we will now be able to implement OOPS principles for SharePoint Code. In other words we can now have an easier way to understand and implement object oriented principles in SharePoint. The short answer on how to do this is - LINQ + SPMetal tool.
I recently started using SPMetal and was amazed how easily I abstracted the logic and got design time checking of web, list schemas, content types, etc.

Overview :- http://msdn.microsoft.com/en-us/library/ee538255.aspx

How to use of SPMetal:- http://msdn.microsoft.com/en-us/library/ee538587.aspx

With Screenshots of SPMetal with External List:- http://fabiangwilliams.wordpress.com/2010/01/03/how-to-using-spmetal-utility-in-sharepoint-2010-to-presumably-manipulate-data-on-a-bcs-external-list/

Sample from Codeplex:-  http://linqtosharepoint.codeplex.com/wikipage?title=SpMetal&referringTitle=Home

Saturday, November 2, 2013

Research Work on Existing Mobile Banking Products

My Professor used to think about me as A VERY GOOD BOY because I used to take books to the class when none attended his class. But he never knew the fact that in the book I used to have a photo of my girlfriend and the reason to attend the class was to have a chance to flirt with her.

I wouldn't blame my Dad for spoiling me by buying me a Mobile. With the arrival of a mobile, my attendance started to decline and thanks for the Providers who given attractive offers. Then my love started towards Mobile too where it went lot of sleepless nights of what it is doing and what it can be done. As I entered my career into Banking Sector Company added more brainstorms and clear picture of Mobile Banking Area.  

Even though my lovely things are filled into my Mobile, I am still having hard time with filling up my Pockets with Money Purse & Cards Pouch. Even some place it made already replacing Money Purse with only Card Pouch but I say that its not TOTALLY. Then the way of thinking went in finding the thing which replaces all into One or else even nothing should be.

Of course as of now I got an idea of replacing the Three Money purse, Cards Pouch & Mobile into One. That is Mobile itself. Let me tell clearly how it will be and What it all can do.

Already in the Market there are many Cellphone Banking Products and Money Transfer Services, where initially I thought no such exists in the market.
  • M-PESA                     
  • SharPay -
                    http://www.youtube.com/watch?v=wV7fd6ioG7M
  • WIZZIT
  • YUCASH
  • ZAP
Hope you all got many doubts right from Security ,Speed etc., I too accept with you but to be say once more in Simple words NOTHING IS IMPOSSIBLE. Especially the Aggressive TEAM works..I tried best to take some info through Web and Personal Interaction with Leaders in the Market and framed a few roles and respective Queries...!!

CIO's Clarifications
What would be the RoI? What about confidentiality of data? These are obvious questions management would ask a CIO trying to implement mobile applications. Adopting any mobile application is an expense, with no assurance of direct returns. E.g., customers may use a bank's short code toll free but the bank has to pay the application providers and the operators.

Of course, returns are in the shape of better customer focus. If customers get better service they remains loyal and brings in more business. It becomes a great tool in acquiring new customers and retaining old ones.

In the B2B space it gives employees flexibility in business execution and makes the whole process efficient and reduces the turnaround time. Employees have everything on the mobile and don't have to rush to the office for data or consultations before closing deals. Such application gives obvious competitive advantages.

Overall, workforce and IT infrastructure is optimally utilized, which in the long run reflects in the company's balance sheet.

Thursday, October 31, 2013

Finding SharePoint Item Level Permissions in ECMAScript


In EMAScript, to find out item level permissions in a list/library we don’t have respective
object in CurrentItem which states with Permission Name. Generally if we do the same in
 Server Object Model it returns Permission Names in string format. This ease our task but
in ECMAScript it returns in nvarchar format.

For Example, to know whether item has Read Permission, below is the snippet code.

if (ctx.CurrentItem.PermMask == "0xb008431061") { //This value is for Read Permission
}
else {
}

Wednesday, October 30, 2013

Solution for Nintex forms 2013 not working with Custom Master Page in SharePoint 2013


 Problem:-
I am using custom master page and installed the Nintex forms 2013 in my SharePoint 2013 environment.
When I click on any New Item which contains the Nintex form getting below error.

The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.

Solution
The resolution steps are

Step 1:- Find the below lines from header:

<SharePoint:AjaxDelta id="DeltaSPWebPartManager" runat="server">
<WebPartPages:SPWebPartManager runat="server"/>
</SharePoint:AjaxDelta>

Step 2:- Cut it out...Go to the body part... find div with the id "s4-workspace" and paste the code before this div like this:
<SharePoint:AjaxDelta id="DeltaSPWebPartManager" runat="server">
<WebPartPages:SPWebPartManager runat="server"/>
</SharePoint:AjaxDelta>
<div id="s4-workspace">
[...]
 

Alternative for Connectable Webparts [Filter SharePoint list with Partial Postback to page]


Problem:-
The other day, I wanted to filter a list view web part, triggered from some action in the same page.
Every time I do action, I wanted to automatically filter the sharepoint list with that value, without
doing a full postback/refreshing the page.

Solution
Generally as SharePoint developer will get an idea to develop a connectable webparts, but this is
difficult and takes time. The alternative is from SharePoint 2013, we have a new page added in
layouts folder inplview.aspx. This generates the "inplviewhash" tag when we do filtering/sorting and
mainly it appends with "#" in url. As we know when we have # url, the page doesn’t gets reload[postback].

For Example:- If we have two webparts in the Page containing one action performed and second
showing respective filtered data. The approach is when we do action in the above webpart through
javascript frame below way of url.

Function createFilterURL() {
var filterstring += //Frame query string which contains the formatted of filterfield1,filtervalue1 [if multiple values filterfields1,filtervalues1].
var wpqschema = ctx.View;
var querystring +=  '#InplviewHash' + wpqschema.slice(1, -1).toLowerCase() + '=' + filterstring ;
window.location.hash = querystring;
}

Friday, October 18, 2013

Configure Audit Settings in SP 2013 Programatically

As you may get a requirement to configure Audit Settings for a Site Collection/ Web/List of SharePoint through Programatically. Listed out below the respective API and Methods which help for better understanding.

  • Regarding setting up storage location to save audit entries. By default the audit logs in sharepoint will save in the sharepoint database. If you want to store in particular document library, we need to below way. 
using Microsoft.Office.RecordsManagement.Reporting;
{
....
AuditLogTrimmingReportCallout.SetAuditReportStorageLocation(site, "{Documents Library Name}");
....
}
        For more detailed info please see
http://msdn.microsoft.com/en-us/library/microsoft.office.recordsmanagement.reporting.auditlogtrimmingreportcallout.setauditreportstoragelocation.aspx

  •   Regarding Setting up the Retention period, this is a straight forward where we have the respective property.       

      site.TrimAuditLog = true;
      site.AuditLogTrimmingRetention = 30;

  •  Be default the retention period will be 60 days in SharePoint.

Sunday, August 4, 2013

Encrypting or Decrypting Web.config properties

If we are using applications in our internal servers with security then it’s ok. If we deploy our applications in shared host environment then we have chance to arise security problems to avoid these problems from asp.net 2.0 provided built in protected configuration model functionality to encrypt or decrypt few sections of web.config file those are
 
RSAProtectedConfigurationProvider: This is default provider and uses the RSA public key encryption algorithm to encrypt and decrypt data.
 
DataProtectionConfgurationProvider: This provider uses windows data protection application programming interface to encrypt and decrypt the data.
 
The encrypting and decrypting of connection strings in web.config file will do by using aspnet_regiis.exe command line tool and code behind.
Before encrypting the connectionString the web.config looks like this:



Steps to Encrypt your connectionStrings:

1)  Go to All Programs>Microsoft Visual Studio 2012> Visual studio tools> Developer command prompt for VS2012.

2  2)  Right click on it and choose run as administrator.

3  3)  Type the following command in the prompt:
Here –pe indicates that the application is built as IIS based site. Second argument connectionStrings is the name of configuration section needs to be encrypted. The Third argument -app indicates virtual directory and last argument is the name of virtual directory where application is deployed. 

4)  And execute it your prompt you will see succeeded message as follows: 


1  5)  Now go and browse your web.config file which looks something like this:

                      Here you may doubt that “What if I want to use the connection string in cs file”. The .net framework automatically decrypts it.

Steps to Decrypt connectionStrings:
1  1)  Go to All Programs>Microsoft Visual Studio 2012> Visual studio tools> Developer command prompt for VS2012.

2  2)  Right click on it and choose run as administrator.

3  3)  Type the following command in the prompt:
 4)  And execute it your prompt you will see succeeded message as follows:

1  5)  Now go and browse your web.config file which looks something like this:

Thursday, March 14, 2013

Part 1 - Create RESTful WCF Service

This is the first part about building Windows Communication Foundation (WCF) services using the architectural style known as Representational State Transfer (REST). You may know that this got famous from the time of its existing around 2000.

Let me start with basic understanding and then the implementation of RESTFul WCF Service.

Brief:-


WCF service will use SOAP, but if you build a REST service, clients will be accessing your service with a different architectural style (calls, serialization like JSON, etc.). REST uses some common HTTP methods to insert/delete/update/retrieve information which is below:
  1. GET - Requests a specific representation of a resource
  2. PUT - Creates or updates a resource with the supplied representation
  3. DELETE - Deletes the specified resource
  4. POST - Submits data to be processed by the identified resource

Implementation:-
In my first implementation, let me explain the GET method.
  • Open your Visual Studio 2012, Go to New Project as below. Give the Name and Location and Click Ok.


  • You will get default solution structure in the Solution Explorer.

  • You can Rename or can use the sample .svc files. In my case I am just renaming the files to easy readable format. as Service1svc to ExampleService.svc and interface IService1.cs to IExampleService.cs
namespace SampleRestFulWCFService
{
    [ServiceContract]
    public interface IExampleService
    {
        [OperationContract]
        [WebInvoke(Method = "GET",
          UriTemplate = "GetData/{id}",
          ResponseFormat = WebMessageFormat.Json,
          BodyStyle = WebMessageBodyStyle.Wrapped)]
        string GetData(string value);
    }
}

  • Now open the ExampleService.svc.cs file and create a method with name GetData as below
public string GetData(string value)
{
return "You entered the Value:"+value;
}

  • Build and browse the Application.
  • By default it opens the URL containing the ExampleService.svc for eg:- http://localhost/SampleRestFulWCFService/ExampleService.svc
  • Add the following string in the URL as "/GetData/Sample" which means http://localhost/SampleRestFulWCFService/ExampleService.svc/GetData/Sample
Now you will see as "You entered the Value: Sample" This is a JSON Object. 

MVC Application - Not able to browse

Sometime when you are browsing the MVC Application through your IIS Server, you may facing an issue of not able to browse. You may see the Directory list rather than Home Page. In that case, please add below line in your web.config file under the System.WebServer tag.

 <modules runAllManagedModulesForAllRequests="true"></modules>

Now once restart the Website in your IIS and browse your MVC Application. Hope you can enjoy now.

Please post if any issues still arises.