Monday, December 22, 2014

Linked Data Source Joining


 
To work with inked data source join,
there must be one common column relationship between two lists.
Otherwise it is not works.
do following Steps:
Step: 1
Create two Lists with Names as Indent Request and Indent Response
and its common column name is     MOC ID NO
Step: 2
Create linked data source(JoiningLists) using these two lists with join selection.
Step: 3
Create web part page
Step: 4
Create Data View web part

Step: 3
Open SharePoint designer with respective site url
On the left pan click on site Pages
Click on Web part page
Give name: JoiningLists
Click on between the web part zone
<WebPartPages:WebPartZone runat="server" Title="loc:FullPage" ID="FullPage" FrameType="TitleBarOnly">
<ZoneTemplate>
On the Top of ribbon select Data view
Next click on More Data Sources
Select Linked data source: JoiningLists
Next click on OK and save &Next click on the title field td
Click on common column in the response table


 

Next Click on data source dropdown and Select joined subview. It opens following popup so we need to select common column in both table MOC ID NO and click on OK

Comment the column heading of the response list as follows.

 
Add required column names in dvt_2.rowview  
 
 
Add column heading the top of heading column names only.
By adding the bellow code after columns heading we can get total record count on the top of page 
 

By adding the bellow code after group column name
we can get group wise rows count as follows


Note: if the columns are not displayed in the same column information then give fixed width for column title and column data  
After this also not displayed in the proper manner give class name “table” for columns heading table.
<table border="0" width="100%" cellpadding="2" cellspacing="0" class="table">
Example:
 

Cascaded Dropdown List in SharePoint List




1.Create List Name with Country
   Create Country Column  with single line of text

 
2.Create List Name with State
   Create State Column  with single line of text
   and Create Country lookup column

  
 
3. Create Employee List with 2 lookup columns State and Country using Above Two lists
    and required columns.
   Open the NewForm.aspx add the bellow code after Main Content Place Holder
 
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server" >
<script type="text/javascript" src="../../SitePages/JS/jquery-1.10.2.js"></script>
<script type="text/javascript" src="../../SitePages/JS/jquery.SPServices-0.7.2.js"></script>
<script type="text/javascript">   
$(document).ready(function()
{               
  $().SPServices.SPCascadeDropdowns(
  {
    relationshipList: "State",
    relationshipListParentColumn: "Country",                    
    relationshipListChildColumn: "State",                    
    relationshipListSortColumn: "ID",                    
    parentColumn: "Country",                    
    childColumn: "State",                   
    promptText: "Choose State...",                    
    debug: true               
  });    
}); 
<script>

Relation Ship Explanation As Follows:
 After Adding the Above Code Result as follows.
 

Friday, December 19, 2014

FBA in SharePoint 2013

Description:

Today we are going to see how to Configure Forms Based Authentication in SharePoint 2013. In SharePoint, Microsoft offering two different types of authentication such as Windows Authentication and Forms Based Authentication. By default we will get the windows authentication to our site but if we want to provide the Forms based authentication to our SharePoint site we must have to do some settings while creating of web application of a site. Now we will see step by step process of configuring forms based authentication in SharePoint 2013.
What is Windows Authentication in SharePoint?
Windows authentication is a secure form of authentication which is offered by Microsoft and the user name and password are hashed before being sent across the network. When you enable the Windows authentication in our SharePoint Site, the client browser sends a strongly hashed version of the password in a cryptographic exchange with our Web Server. We will get the users information such as username, password, role, and group he/she belongs, from the Active Directory and store the user information into content database of SharePoint, this will happens in installation process of SharePoint Farm or we can do it after installation of SharePoint using user management services in SharePoint.
What is Form Authentication in SharePoint?
Some companies maintain their employ user information in databases rather than Active Directory. So here all the users information such as usernames, passwords, roles and groups will stored in a database that may be MS SQL, Oracle or MySQL in this type of situations most of the companies will prefer to use form based authentication instead of rebuild the new Active Directory.

Steps to work with FBA
1  1. Create Database
    2. Create Web Application
    3.  Modify 3 web. Configuration files
i.             FBA  (web Application) 
ii.           Central Administration
iii.          STS (Security service Token)
    4.Set user policy

Step-1: Create Database

Create Database using aspnet_regsql.exe Application
Go to the location C:\Windows\Microsoft.NET\Framework64\v4.0.30319

And select aspnet_regsql.exe  right click select run as administrator



 It opens
  è ASP.Net SQL server Setup wizard
  è Click on next button
  è Select the SQL server for application services and click on next button
  è Select the server and data base details
     Server: SQL Server Name (System name) (ex: HYD38)
     Select authentication type windows
     Database Name: FBADB
  è Click on next button and next and finish.
Note: Check the database name FBADB and its table’s names (like users, roles  ...Etc.)  In SQL Server

Step step2: Create Web Application

  è Go to central administration
  è Click on Application management
  è Click on new
  è Give following details 




Click on OK.

Web application creates and it asks you want create site collection
Click on Create Site Collection page. 

Create Site collection:
Give site title, template name and primary site collection administrator name
Click on OK button

Step3: Modify 3 web. Configuration files
i.             FBADemo Web Application web.config file (Add connection string, Membership provider and role provider)

Go to IIS
Go to run command (Window+R)
  è Enter inetmgr
  è Press enter button it open IIS
  è Go to sites
Click on web application (FBADemo – 6666)

a.   Connection string

In middle pan double click on Connection Strings icon
On the right pan click on Add and the enter the details bellow



Click on OK button.
b.    Member ship provider

Click on web application (FBADemo – 6666)
In middle pan double click on Providers icon
In middle pan select feature type .Net User


On the right pan click on Add and the enter the bellow details 


Click on Ok button

c.    Role provider :

Click on web application (FBADemo – 6666)
In middle pan select feature type .Net Roles


On the right pan click on Add and the enter the bellow details 


Click on Ok button

d.   Create role
Click on web application (FBADemo – 6666)
In middle pan double click on .net Roles icon and it displays following error message



We need to change default role provider to FBARoleProvider

So click on right pan set Default provider
And change default provider ‘c’ to FBARoleProvider 




Click on OK

Click on add right pane and give role name r1


Click on OK
Similarly create other roles like r2, r3, etc.

e.   Create User
Click on web application (FBADemo – 6666)
In middle pan double click on .net Users icon and it displays following error message


We need to change default member ship provider to FBAMembershipProvider

So click on right pan set Default provider
And change default provider ‘i’ to FBAMembershipProvider
Click on OK
Click on add right pane and give the details 


Click on next
Select role type r1 and click on finish.
Similarly create other users like user_02, user_03 etc.

Note: revert to default membership provider FBAMembershipProvider to ‘i’            and default role provider FBARoleProvider to ‘c’
   If you got any error message just click on OK.

i.             Click on web applications (SharePoint Central Administration v4)
Repeat the steps in above web application (FBADemo – 6666)
a, b, c ( Connection string , member ship provider  and role provider) details

ii.            Click on web applications (SharePoint Web Services)
        Repeat the steps in above web application (FBADemo – 6666)
             a, b, c ( Connection string , member ship provider  and role                     provider) details

Note: In central admin we need to change default Membership provider
ASPNetSQLMembershipProvider  to FBAMembershipProvider 


             Similarly Change
            Default Role provider
            ASPNetSQLRoleProvider to   ASPNetWindowsTokenRoleProvider
1.   Set user policy

Go to center Admin select the FBADemo Web Application
Click on user policy on the top of the ribbon
Next click on Add users
Next select “All zones”
Next select the User: user_01 or All Users (FBAMembershipProvider)All Users (FBAMembershipProvider)
And Permission: full control
Click On finish.
Note: Uncheck the anonymous access to the web application. If you are not added user to user policy you got following message
Sorry, this site hasn't been shared with you. 
So in user selection you can select All Users (FBAMembershipProvider)All Users (FBAMembershipProvider) instead of user_01

Note: if the site users have different permission levels so you can create separate groups for users i.e. Viewers, Members and Owners. Add these users to respective groups while creating the users at registration page.

Apply FBA permission to List
Go to list
Click on list settings
Next click on permissions for this list
Next Click on stop inheriting permission
It display one popup like create unique permissions for this?
Click on OK
Next click on grant permissions on the top of the ribbon
Enter All Users (FBAMembershipProvider)
Click on show hide option select permission contribute, next click on Share.



Friday, November 21, 2014

Timer job errors and solutions in SharePoint

Introduction


In this post we will see what the various errors that come while handling Timer Job in SharePoint.
These errors are sometime common for many developers but could take time to resolve. Hope this will resolve your errors and save your time.
Don’t miss the article how to create Timer job for specific site in SharePoint

What are the points that are covered

  • Frequent errors that come up with Timer job and their resolution



Error: Access denied while creating/deleting the Timer job from the feature


We may encounter the following error while activating the feature from UI and inside the feature activation code we have code to create/delete Timer job


Access denied.
at Microsoft.SharePoint.Administration.SPPersistedObject.Update()
at Microsoft.SharePoint.Administration.SPJobDefinition.Update()
at xxx.xxx.<>c__DisplayClass1.b__0()



Solution


Activate the feature from command prompt rather than from the UI and we won’t be getting the above error
Following is the quick code to activate or deactivate the feature by stsadm


Activating the feature
stsadm -o activatefeature -fileName TimerJobFeatureReceiver\Feature.xml -url http://adicodes/sites/mysite -force


Deactivating the feature
stsadm -o deactivatefeature -fileName TimerJobFeatureReceiver\Feature.xml -url http://adicodes/sites/mysite -force



Error: Timer job running more than once


This is one common error many users face. For example, we have written sending email while Timer job executes. It will be so annoying if users says that they got more than one email with same content and time stamp.

Solution
This duplicate job running behavior is due to the SPJobLockType in the constructor.
Suppose if we are using this constructor

public TimerJob(SPWebApplication webApp): base("TimerJob", webApp, null, SPJobLockType.ContentDatabase)
{
this.Title = "TimerJob";
}

Timer job will execute more than once if the web application for which Timer Job is associated has more than one content database
We can check the number of content databases for the webapplication from central admin site
Go to http://centraladminurl/_admin/CNTDBADM.aspx. Select the webapplication and we can check the number of content databases associated with it

Change the SPJobLockType enumerator value from ContentDatabase to Job in the constructor as follows

public TimerJob(SPWebApplication webApp): base("TimerJob", webApp, null, SPJobLockType.Job)
{
this.Title = "TimerJob";
}


Now, the Timer job will execute only once though there are multiple content databases associated

You can check what the SPJobLockType enumeration is for at
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spjoblocktype.aspx


Error: access denied While Updating the timer Job

override bellow method in Job definition class before or after execute method

protected override bool HasAdditionalUpdateAccess()
        {
            return true;
        }
 
protected override Execute()
{

}

Error: Latest code is not running after Timer job is deployed


This is also one common error many users face. They get surprised why the latest deployed Timer job code is not running and sometimes get the
following error

OWSTIMER.EXE (0x0AAC) 0x0BF0 Windows SharePoint Services Topology 7i0u High SharePoint cannot deserialize an object of type Pages.SurveySiteEmailJob, Pages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c475c2fd38120dac on this machine.
This typically occurs because the assembly containing this type is not installed on this machine.
In this case, this message can be safely ignored. Otherwise, the assembly needs to be installed on this machine in a location that can be discovered by the .NET Framework.


Solution


Just restart the timer service
How to restart the Timer job service in SharePoint 2010

Go to Start > Run (Windows Key+R)
Type Services.msc and hit enter or click on OK.
Under services locate “SharePoint 2010 Timer”.
Stop and Start service

or
with command line code
net stop “SharePoint 2010 Timer”
net start “SharePoint 2010 Timer”

How to restart the Timer job service in SharePoint 2007
Go to Start > Run (Windows Key+R)
Type Services.msc and hit enter or click on OK.
Under services locate “Windows SharePoint Services Timer”.
Stop and Start service
or
with command line code
net stop “Windows SharePoint Services Timer”
net start “Windows SharePoint Services Timer”

Conclusion


We might have tried a lot for figuring out what is the cause of the error. Hope the the above resolutions will save your time.
You can add up some more bugs if you encounter, so that it will be helpful for any SharePointers:)

Friday, October 31, 2014

check edit permission on a specific list/web using ecma script


I.Add Script two files
1.jquery-1.8.2.min.js
2.jquery.SPServices-0.7.2.min.js
in the bellow Content Place Holder
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">

<script type="text/javascript" src="../../SiteAssets/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../../SiteAssets/js/jquery.SPServices-0.7.2.min.js"></script>
II. Call function in the document.Ready function
using following code we can check user permission (edit) on a specific list
var _currentUser;
var _theList;
function Editpermissions()
{       
    context = new SP.ClientContext.get_current();
    web = context.get_web();
    this._currentUser = web.get_currentUser();
  // here mention list name ex: employee
    this._theList = web.get_lists().getByTitle('employee');
    context.load(this._currentUser);
    context.load(_theList, 'EffectiveBasePermissions');  
    context.executeQueryAsync(Function.createDelegate(this, Success), Function.createDelegate(this, Failure));
}
function Success()
 {
   if (this._theList.get_effectiveBasePermissions().has(SP.PermissionKind.editListItems))
    {
       alert('User Can Edit the list.');
    }
    else
    {
       alert('User Can NOT Edit the list.');
    }
}
function Failure()
{   
  alert('unable to perform the action');
}
using following code we can check user permission (edit) on a specific web
 function checkpermission()
 { 
      var context;    
      context = new SP.ClientContext.get_current();
      web = context.get_web();
      context.load(web, 'EffectiveBasePermissions');   
      context.executeQueryAsync(onSuccess, onFailure);  
 }
 function onSuccess()
 {
    if (web.get_effectiveBasePermissions().has(SP.PermissionKind.manageWeb))
     { 
     alert('User Can Edit the list.');
    }
}
 function onFailure()
 {
   alert('unable to perform the action');
}

Thursday, October 30, 2014

Retention Policy in SharePoint 2013

Retention:
The Retention policy feature lets you define retention stages, with an action that happens at the end of each stage. For example, you could define a two-stage retention policy on all documents in a specific library that deletes all previous versions of the document one year after the document is created, and declares the document to be a record five years after the document is created.
The actions that can occur at the end of a stage include the following:
àMoving the item to the Recycle Bin
àPermanently deleting the item
àTransferring the item to another location
àStarting a workflow
àSkipping to the next stage
àDeclaring the item to be a record
àDeleting all previous drafts of the item
àDeleting all previous versions of the item
Auditing:
The Auditing policy feature logs events and operations that are performed on documents and list items. You can configure Auditing to log events such as the following:
àEditing a document or item
àViewing a document or item
àChecking a document in or out
àChanging the permissions for a document or item
àDeleting a document or item
· Opening or downloading documents, viewing items in lists, or viewing item properties
· Editing items
· Checking out or checking in items
· Moving or copying items to another location in the site
· Deleting or restoring items
Labeling:
The Labeling policy feature specifies a label to associate with a type of document or list item. Labels are searchable text areas that SharePoint Server 2013 generates based on properties and formatting that you specify. For example, in a law firm, a document related to a legal matter could include a label that contains the clients' names, the case number, and the attorney assigned to the matter. Labels are especially useful in printed versions of documents as a way to display document properties in printed copy. Along with using labels for documents, you can associate a label with a list item and include that label in views of the list.
Note:
The label policy feature has been deprecated and should not be used in SharePoint Server 2013.
Barcode:
The Barcode policy feature enables you to track physical copies of a document by creating a unique identifier value for a document and inserting a bar code image of that value in the document. By default, bar codes are compliant with the common Code 39 standard (ANSI/AIM BC1-1995, Code 39), and you can plug in other bar code providers by using the policies object model.
Example: Move Records to Recycle bin using Working retention policy:
àCreate one List with required columns.
àActive the Site Collection Feature: Library and Folder Based Retention
àActive the Site Feature: Content Organizer
àSet Retention policy to list
àGot List sittings
àNext click on Management Information Policy settings
àNext click on Item content type
àCheck the enable retention
 àNext click on Add retention stage
Event: Select created + 1 Month
Action: Move to recycle Bin
 Click On Ok.
5. Run the timer job Expiration policy from central Administration
Now one Month above Records are deleted.



Note: If you want remove or run the workflow based some column status
So you create one site column and add that column to list
This column now appear in Event: Time Period

Features Related to retention policy are
1. Site Collection Feature: Library and Folder Based Retention
2. Site Feature: Content Organizer
3. Timer jobs :Expiration policy & Information management policy