Disable right click on SQL reporting services report in SharePoint 2007


We are working on SharePoint Workspace with Business Intelligence solution. There some report build with reporting services show in SharePoint page. Then, we come across a special requirement that the client do not allow user to “Right click” on the entire SharePoint page including the reports. If you are using page viewer or report web part to view the report in native mode, you will never able to include your JavaScript to disable the right click. This is because it using iFrame to link to the report. To overcome this problem, there are 3 steps need to be done.

  1. Install and configure Reporting Services Add-in for SharePoint
    First, we need to install the “Microsoft SQL Server 2005 Reporting Services Add-in for Microsoft SharePoint Technologies” add-in and change reporting services to SharePoint integration mode. You can download the add-in in https://www.microsoft.com/downloads/details.aspx?familyid=1E53F882-0C16-4847-B331-132274AE8C84&displaylang=en  and get some introduction on its benefit here http://blogs.msdn.com/SharePoint/archive/2007/02/19/microsoft-sql-server-2005-sp2-reporting-services-integration-with-wss-3-0-and-moss-2007.aspx . You need to configure the reporting services after installed the add-in. You can easily find some help via google. Once done, you have to upload some report to SharePoint document library.
  2. Add JavaScript to disable the right click on SharePoint.
    To simplify the story, we use Content Editor Web Part to ad in the JavaScript. Enter code below in “Source Editor”:
    <SCRIPT language=”JavaScript” >
    function queryString(parameter) {
      var loc = location.search.substring(1, location.search.length);
      var param_value = false;
      var params = loc.split(”&”);
      for (i=0; i<params.length;i++) {
          param_name = params[i].substring(0,params[i].indexOf(’='));
          if (param_name == parameter) {
              param_value = params[i].substring(params[i].indexOf(’=')+1)
          }
      }
      if (param_value) {
          return param_value;
      }
      else {
          return false; //Here determine return if no parameter is found
      }
    }
    function right(e) {
    if (navigator.appName == ‘Netscape’ &&
    (e.which == 3 || e.which == 2))
    return false;
    else if (navigator.appName == ‘Microsoft Internet Explorer’ &&
    (event.button == 2 || event.button == 3)) {
    alert(”Sorry, you do not have permission to right click.”);
    return false;
    }
    return true;
    }
    document.onmousedown=right;
    document.onmouseup=right;
    if (document.layers) window.captureEvents(Event.MOUSEDOWN);
    if (document.layers) window.captureEvents(Event.MOUSEUP);
    window.onmousedown=right;
    window.onmouseup=right;
    </script>
    addin01.jpg
    The right click will disable on the specify page now.
    Read the rest of this entry »

BSM 2005 defaultmember in MS OLAP Cube


I am having  difficulties to set the dynamic defaultmember for a dimension. Eg. I got a time dimension which use in BSM. I want it to always get today’s date as the dimension member so that i can get the MTD data from my cube. But some how it didnt works. I did try on vba!date() function as found in google as well but no help. The BSM time intelligence member only work and display data if i hard code the defaultmember in cube. Setting manually time dimension in BSM also no help. Does anybody facing this problem before? Will appreciate if can point out the tricks…. =)

Custom properties for custom webpart in wss 3.0


Writing custom properties for your own web part isn’t that complex. Here is a simple example to do that.

using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using System.Web.UI.WebControls.WebParts;

namespace SampleWebPart
{
    [DefaultProperty("DisplayText"),
      ToolboxData("<{0}:Sample runat=server></{0}:Sample>"),
       XmlRoot(Namespace = "SampleWebPart")]
    public class Sample : WebPart
    {
        private string displayText = “Hello World!”;
        [WebBrowsable(true), Personalizable(true)]
        public string DisplayText
        {
            get { return displayText; }
            set { displayText = value; }
        }
        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            writer.Write(displayText);
        }
     }
}

Convert text to speech on the fly


Do you ever come across customer’s requirement to convert text (like NEWS) to speech files such as wav, mp3, etc easily?  Especially the customer wants to create mp3 directly and attaches it to the news he has just published in MOSS. Here is a good start… http://www.codeproject.com/audio/speech.asp

In this project they made an application program for Text-to-Speech Conversion. To build this application, we must install the SDK speech from Microsoft on our computer (download Speech SDK (it’s free) from http://www.microsoft.comm/speech)

The SAPI API provides a high-level interface between an application and speech engines. SAPI implements all the low-level details needed to control and manage the real-time operations of various speech engines. As mentioned it will required some custom code.

Connected webparts from two different pages…


If you have two aspx pages (sharepoint views) and need to pass some value from the parent view (aspx page1) to the child view (aspx page2) based on the user selection and filter the second view based on that parameter. Please check it out here…

http://www.theserverside.net/tt/articles/showarticle.tss?id=WebParts2

Create groups programmatically in WSS 3.0


Here are some simple codes to do it:

1. Add the group (newMembersGroup)
2. Set the permissions of the group (role assignment) to contributor
3. Add the author to the group.
4. Associate the group to the site.
Dim groupOwner As SPUser = site.Author
site.SiteGroups.Add(newMembersGroup, groupOwner, Nothing, “”)

Dim membersGroup As SPGroup = site.SiteGroups(newMembersGroup)
membersGroup.OnlyAllowMembersViewMembership = False
membersGroup.AllowMembersEditMembership = False
membersGroup.AllowRequestToJoinLeave = True
membersGroup.AutoAcceptRequestToJoinLeave = True
membersGroup.Update()

Dim contributor As SPRoleDefinition = site.RoleDefinitions.GetByType(SPRoleType.Contributor)
Dim membersRoleAssignment As SPRoleAssignment = New SPRoleAssignment(CType(membersGroup, SPPrincipal))
membersRoleAssignment.RoleDefinitionBindings.Add(contributor)
site.RoleAssignments.Add(membersRoleAssignment)
‘Add the site author as a member
membersGroup.AddUser(site.Author)
membersGroup.Update()
site.AssociatedMemberGroup = membersGroup
site.Update()
More info in Role Assignments: http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.sproleassignment.aspx

More info to create your Group (now Cross Site Groups) : http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.spgroupcollection_methods.aspx

How to install and deploy BSM 2005 into MOSS 2007


Business Scorecard Manager 2005 is not supported officially in MOSS 2007. Here are some work around to make it work.

To install BSM 2005:

  1. Make sure all prerequisite software like ADOMD.NET and msxml were installed.
  2. Run updateBSM.vbs update registry for SharePoint site. You need to run it again when creating a new site.
  3. Proceed to run server.msi and builder.msi

To deploy BSM 2005 to MOSS:

  1. In your MS Business Scorecard Builder IDE, proceed to deploy to SharePoint site as usal. The newly deployed page never work. We just want to deploy necessary web parts and it’s scorecard entry to SharePoint server.
  2. To view the Scorecard, add “Office Scorecard View” and “Office Report View” web part to your page. If you encounter error web part cannot desirable, make sure you add in the
    <add key=”Bpm.ConnectionString” value=”Integrated Security=SSPI;Initial Catalog=ScorecardServer; Data Source=(local)”/>
    in web.config under appsetting and change the data source accordingly.
  3. Once web part added, just modify the web part as usual to select your Scorecard and View.

Adding item to sharepoint 2003 SPList Programmatically


I come accross some problems when adding new item to a SPList. The error i got is “Value does not fall within the expected range. ” This would only happen if you target list is empty. After do some googling, this seems is MS known bugs. Luckly there is workarround to solve this issue. Simple rules is

1. Add a new item, assign “Title” item and save it

2. Get the newly created item and update it with remaining items.

Here are the codes:

SPListItem newListItem = spList.Items.Add();

newListItem["Title"] = “The title”;

newListItem.Update();

SPListItem existingListItem = spList.GetItemByID(newListItem.ID);

existingListItem[2] = “Category 1″;

existingListItem.Update();

P/s: You only need to add new item as in this way for the empty SPList. Once u have at least one item.. the error will gone.

Please visit the original article: http://blog.buro9.com/2007/02/26/sharepoint-splistitem-quirks for more information…

Setting audience user group in MOSS 2007


I spent some time to find out why my AD groups do not appear while add a user rule in my new audience. Finally i found that we have to start a full import user profile to solve this problem. After import profile done, wait for few seconds….Why? You cannot get the group immediately. I guess MOSS  may take some time to process and propagate to shared services… So just wait a moment and you will get it right away… =)