Category Archives: ASP.NET

Reading from web.config’s AppSettings in a SharePoint timer job

csharpSharePoint-2013

Well, this was not as straight-forward as i first thought. Why? Because the timer job does not run in the same App Domain as the web application. They are in two separate processes : W3WP.EXE  and OWSTIMER.EXE for the Web Application worker process and the SharePoint timer respectively.

So, how do you go about it?

Well, firstly you need to add reference to your timer job as follows (unless your using VB !):

using System.Configuration;
using System.Web.Configuration;

Reading AppSettings in Timer

using (SPSite site = new SPSite(“http://SiteCollectionUrl"))

        {

            Configuration config = WebConfigurationManager.OpenWebConfiguration(“/”, site.WebApplication.Name);

            returnconfig.AppSettings.Settings[“AppSettingKeyToRead”].Value;

        }

Admittedly, this solution is hard coding the Uri of the Site Collection, but this is purely for demonstration purposes.

Get absolute URL to listitem’s default display form – Sharepoint2013

csharp

Problem : 

I need to have an absolute URL of a listitem’s display form – currently I do it the following way:

On http://mydomain.com/:

item.ParentList.ParentWeb.Url.TrimEnd('/') //"http://mydomain.com"
+ "/" 
+ item.ParentList.DefaultDisplayFormUrl.Trim('/')//"Lists/WorkflowTasks/DispForm.aspx"
+ "?ID=" + item.ID //"?ID=1"

This gets me the correct URL, meaning http://mydomain.com/Lists/WorkflowTasks/DispForm.aspx?ID=1.

However this fails when my site collection is on a slightly more sophisticated host url, for examplehttp://mydomain.com/sites/secondsite/ – both methods from my code return the url containing the “/sites/secondsite/ part so I end up with http://mydomain.com/sites/secondsite/sites/secondsite/Lists/etc

How do I code it in a more reliable way?

Solution :

There are a couple of methods for this available in the object model without the need to handle the slashes etc yourself, one method using MakeFullUrl:

var fullUrl = item.ParentList.ParentWeb.Site.MakeFullUrl(item.ParentList.DefaultDisplayFormUrl);

Also

+ "?ID=" + item.ID //"?ID=1"

Resolved.

10 Best Productivity Features in SharePoint 2013 – slideshare

SharePoint-2013

Slide from webinar. A walkthru of the Top 10 productivity features in SharePoint 2013. It explain why a productivity focus is important, and compelling reasons to move to SP2013.

Ref : slideshare

eDiscovery in SharePoint 2013 – An Introduction

SharePoint-2013

More and more organizations face more and more litigations. Whether they are shareholder lawsuits, fraud cases, or competitive investigations, litigation cases have proven to be costly, time consuming, and business disruptive. The new eDiscovery solution of SharePoint 2013 could really help organizations to lower eDiscovery costs, mitigate risks of data tempering or accidental deletion, and minimize business interruption.

In a series of blog articles I’ll show you the benefits of eDiscovery in SharePoint 2013, the architectural concept of the solution, some important implementation considerations, how to get eDiscovery to work technically in both an on-premises situation and in Office 365, and I’ll walk you through an eDiscovery case lifecycle.

But let’s start at the beginning:

What is eDiscovery?

Electronic discovery is the process to identify, preserve, search, process, and produce electronic content or electronically stored information (ESI) for a legal request or investigation.

Basically when we start a new eDiscovery case, we first want to look for possible relevant data, and make sure this data is not tampered with from that moment on (put it on hold). Next we would want to further refine the data set, do a legal review of this information, and then produce it for use in any legal investigation, compliance audit or policy enforcement in the organisation. Finally, when we are ready with the case, we wouldn’t want to forget to release the hold and formally close the case. In a diagram, this whole process would look as follows:

121813_1246_eDiscoveryi1

In SharePoint 2013 (and Exchange 2013), Microsoft did a major overhaul of their eDiscovery solution, resulting in a great tool to support this whole eDiscovery process, without disrupting regular business.

Benefits of using SharePoint 2013 for eDiscovery

With SharePoint 2013 it is possible to run an eDiscovery case on SharePoint, Exchange, Lync, and File Shares (on premises only) at the same time, from one unified central management console. That means it is possible to search, preserve (not for File Shares, we’ll get to that), and export all relevant content of all these repositories from one place.

In SharePoint 2010 it was already possible to perform an eDiscovery process, but this was only SharePoint content related. Exchange 2010 had its own eDiscovery tools. Also, when we would put a site on hold in SharePoint 2010, users would no longer be able to work on the contents of this site. So this was considered a rather business disruptive method.

In SharePoint 2013 these limitations are no longer there. Here’s an overview of what SharePoint 2013, together with Exchange 2013 and Lync 2013, can do for you when it comes to eDiscovery:

  1. SharePoint 2013 has new site templates for both an overall eDiscovery Center, and individual eDiscovery Cases. For every discovery case, you would create a new case site where it is possible to conduct searches, place content on hold, and export content. In addition, you can associate the following things with each case:
    1. Sources: Exchange mailboxes, SharePoint sites, or file shares from which content can be discovered.
    2. eDiscovery Sets: Combinations of sources, filters, and whether to preserve content. eDiscovery Sets are used to identify and preserve content.
    3. Queries: The search criteria, such as author, date range, and free-text terms, and the scope of the search. Queries are used to identify content to export.
    4. Exports: A list of all of the exports that were produced that relate to the case.
  2. With SharePoint 2013 it is possible to centralize eDiscovery management for multiple SharePoint farms, Exchange servers, and File shares. There are a few caveats here, which we will discuss in Part 2 of this blog series when we talk about architectural concepts and considerations (for example, it is not possible to centralize management for a hybrid environment with SharePoint on-premises and SharePoint Online), but as long as you can add a content source or result source to SharePoint Search, you can discover the content from one console.
  3. When you’ve created your eDiscovery Set and did a first general search for all possible relevant content, you probably want to put that content on hold before you start refining your searches and exporting the final content. You want to make sure that whatever happens with the content from that moment on, the original content stays available for your legal case. From the eDiscovery Center it is possible to put SharePoint 2013 sites and/or Exchange 2013 mailboxes on hold, without disrupting the business. End users shouldn’t be affected when content is put on hold and with SharePoint 2013, they’re not. As soon as a SharePoint 2013 site is put on hold, a hidden Document Library is created. Next, when a user modifies or deletes a content item subject to the legal hold, this is still possible for the user, but the original copy of the content item is copied to that hidden Hold Library. In Exchange 2013 mailboxes the same principle is applied by creating a hidden folder where items are actually moved to when a user deletes an item.
  4. From the SharePoint 2013 eDiscovery Center it is possible to export the results of a search for later import in another review tool. Together will all the exported content, an XML file is created which complies with the Electronic Discovery Reference Model (EDRM) specification. So when external (legal) teams use other tools that also comply with this standard, they can easily import the content and use their own tool for further review and analysis. The following content is included in an export:
    1. Documents: Documents are exported from file shares. Documents and their versions (optional) are exported from SharePoint.
    2. Lists: If a list item was included in the eDiscovery query results, the complete list is exported as a comma-separated values (.csv) file.
    3. Pages: SharePoint pages, such as wiki pages or blogs, are exported as MIME HTML (.mht) files, including styling and mark-up.
    4. Exchange objects: Items in an Exchange Server 2013 mailbox, such as tasks, calendar entries, contacts, email messages, and attachments, are exported as a .pst file.
  5. eDiscovery in SharePoint 2013 is rather quick to set up, and easy to use. Of course you need to do some configuration to get SharePoint and Exchange to work together, but this is fairly easy (as you’ll see in one of the next posts in this series). Also, because using the eDiscovery Center is very straightforward, there is no longer the need to burden the IT department with collecting all relevant content in the organization during an eDiscovery process. Legal teams can now be empowered to perform searches and exports themselves. They are able to respond quickly and in full fidelity with real-time data access. Of course there is the matter of governance here, how to handle the required permissions to be able to discover all relevant content, but that’s the case for IT people as well.

Summary

In this post I’ve tried to briefly explain the concept of eDiscovery and what a typical eDiscovery process would look like. Also, I’ve pointed out what’s new in SharePoint 2013 (and Exchange 2013) regarding eDiscovery and how the new eDiscovery Center could really help organizations to quickly respond to cases without disrupting business as usual.

In the next few blog posts I’ll dive more into the architectural concepts of Microsoft’s eDiscovery solution, I’ll talk about some important implementation considerations, how to get eDiscovery to work technically in both an on-premises situation and in Office 365, and I’ll walk you through an eDiscovery case lifecycle.

Ref : eekels

Jquery datepicker problem on date select in IE – ‘length’ is null or not an object

I am posting a wonderful post on Jquery datepicker.
Because I am using Jquery in ASP.NET application, I added a regular expression for date to validate whether user entered date is valid or not. Because of adding the validation on the text box, whenever I select a date from datepicker, the datepicker events are firing like onselect, change etc.. So, generally what validation framework is doing, whenever some event fires on the page, validations will execute. The same thing happening here. Whenever I change or select date from the date picker, it will fire some events and at the same time validation framework trying to validate the validations. But, it is not the right event to do validations. So, always we will get the exception at “vals.length” in a for loop of the built-in code. vals is the object of all the validators on the page. It always fails to load in Jquery date picker event trigger, because it is not the right event for validation. And the result is vals is undefined, you always get exception at vals.length as “length is null or not an object”. I think now you got very clear idea of why it is happening. Now, move to the next step i.e. solution for it.

Solution is very simple, I read all the documentation of Jquery datepicker and found an event named onSelect. So, whenever I select date this is the event firing. So, there I got a clue and started thinking towards it. And below is the result.

$(“.datepicker”).datepicker({ onSelect:function(){}});

In your datepicker initialization statement add onSelect event which don’t do anything means empty function as shown above. There problem solved. Isn’t a good find? Please let me know your thoughts on this.

Ref : praveenbattula

Anchor tags not working in firefox

Here is the simple issue fixed when working with HTML. This is kind of a browser compatibility issue.

In my SharePoint page we have created a CEWP and placed some HTML code along with anchor tag bookmarks features.

But Book marks is working fine in I-Explorer and not working in Firefox.

This got fixed by removing the “#” from the name of the Div tag name of the Bookmark.

SharePoint Content Deployment Successful, but Throwing Event IDs 6398 & 4958

Recently, I launched a public-facing site with a client that utilizes content deployment.  Every 15 minutes, changes from their ‘Content Authoring’ (internal) environment are published out to their read-only Production environment.  For well over a month, things have been working very well, with no errors.  Suddenly the other day, I noticed two events being thrown every time the content deployment job was run:

contentdeployment

Event ID 6398 from the Timer job detail was:

Log Name:      Application
Source:        Windows SharePoint Services 3
Date:          10/15/2009 11:45:15 PM
Event ID:      6398
Task Category: Timer
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      SERVER

Description:
The Execute method of job definition Microsoft.SharePoint.Publishing.Administration.ContentDeploymentJobDefinition (ID 809108c8-7685-46b1-9580-7fa68113a364) threw an exception. More information is included below.

ContentDeploymentJobReport with ID ‘{00000000-0000-0000-0000-000000000000}’ was not found.
Parameter name: jobReportId

Event ID 4958 from Content Deployment had the following detail:

Log Name:      Application
Source:        Office SharePoint Server
Date:          10/15/2009 11:45:15 PM
Event ID:      4958
Task Category: Content Deployment
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      SERVER

Description:
Publishing: Content deployment job failed. Error: ‘System.ArgumentOutOfRangeException: ContentDeploymentJobReport with ID ‘{00000000-0000-0000-0000-000000000000}’ was not found.
Parameter name: jobReportId
at Microsoft.SharePoint.Publishing.Administration.ContentDeploymentJobReport.GetInstance(Guid jobReportId)
at Microsoft.SharePoint.Publishing.Administration.ContentDeploymentJob.get_LastReport()
at Microsoft.SharePoint.Publishing.Administration.ContentDeploymentJob.get_SQMDeploymentJobFlags()
at Microsoft.SharePoint.Publishing.Administration.ContentDeploymentJob.CollectSQMData()
at Microsoft.SharePoint.Publishing.Administration.ContentDeploymentJob.Run(Boolean runAsynchronously)
at Microsoft.SharePoint.Publishing.Administration.ContentDeploymentJobDefinition.Execute(Guid targetInstanceId)’

Now what I found really strange was that even though these errors were being thrown, the content deployment job was running successfully.  The history showed all objects were being exported/imported properly, ‘Successful’ was listed for the status, and the content managers were seeing their changes.  So it was looking like these events were false.

I did some digging through the SharePoint logs after I turned on verbose logging for content deployment, and nothing other than what was already being reported in the Event Viewer could be found.  So I took things one step further – I went over to the SharePoint_Config database, and performed a lookup of the Content Deployment Job Definition GUID from event ID 6398 against the TimerRunningJobs table:

SELECT * from TimerRunningJobs
where jobid = ’809108c8-7685-46b1-9580-7fa68113a364′

And what I found was very interesting:

sqlcdresults

As you can see, the error is related to the Content Deployment Timer Job for Quick Deploy… but in this particular implementation, we are not using Quick Deploy.

So… I disabled the Quick Deploy jobs in Central Administration for my Content Deployment Path, and voila – the events stopped coming up!

qdeploy1

Ref : Jack of all that is Microsoft, Master of None