A reader recently sent me an interesting challenge. They have a large set of reports that are run automatically and saved to the content store. Users may then log into Cognos and viewed the saved output. Now the users want to actually receive the reports in the email. Distribution lists were suggested, but nobody wants to maintain them. So how can we let the users themselves add or remove themselves from these distros, without having to open tickets for always overworked IT staff?
We can set up a stored procedure in the content store to add and remove users from a list. In order to prevent users from signing up to the wrong distro, we can create distro-specific reports with hardcoded values. A secondary benefit of doing it like this is we can ensure that only people who have access to that report can ever sign up.
First, a big WARNING.
This technique requires a connection to the content store. It involves creating two stored procedures that add and remove rows from content store tables. Some Cognos admins have intense aversions to connecting to the content store. While I have tested this technique on my laptop, I have not tested it on your server. I cannot be held responsible for any damage this technique causes, be it losing a distribution list or creating a world-eating blackhole inside the server or any other catastrophic disaster.
Now we can move on to how to implement it.
First, let’s take a look at a distribution list.
I have a grand total of 1 user on my laptop, and I never bothered setting up an auth provider, so I’m using the anonymous user for testing.
The information for this is stored in the content store in the CMREFNOORD2 and CMREFORD1 tables. CMREFORD1 contains the sorting information for the screen, and users won’t appear if they’re not in this table.
As you can see from the SQL, it’s a simple matter to get the table name or the user details. This means we could make a stored procedure similar to:
CREATE PROCEDURE [dbo].[addCAMIDToList] @listName varchar(500) , @camid varchar(500) AS SET NOCOUNT ON; declare @listCMID integer; declare @userCMID integer; declare @maxSort integer; --get the list ID select @listCMID = distName.cmid from cmobjnames distName where distName.Name = @listName --get the user ID select @userCMID = users.CMID from CMOBJPROPS1 users where users.OBJID=@camid --if there's any sorting, we need to know about it here. select @maxSort = coalesce(max(CMREFORD1.ORD),0)+1 from CMREFORD1 where CMREFORD1.CMID=@listCMID begin if @userCMID not in (select refcmid from dbo.CMREFNOORD2 where cmid = @listCMID and refcmid = @userCMID) INSERT dbo.CMREFNOORD2 (CMID,REFCMID) VALUES (@listCMID, @userCMID) ; if @userCMID not in (select refcmid from dbo.CMREFORD1 where cmid = @listCMID and refcmid = @userCMID) insert dbo.CMREFORD1 (propid, cmid, ord, refcmid) values (27, @listCMID, @maxSort, @userCMID); end; SELECT @@ROWCOUNT as "rowCount"
Removing a user from the distro is even easier.
CREATE PROCEDURE [dbo].[removeCAMIDFromList] @listName varchar(500) , @camid varchar(500) AS BEGIN tran SET NOCOUNT ON; delete distMembers from CMREFNOORD2 distMembers inner join cmobjnames distName on distName.CMID = distMembers.cmid inner join CMOBJPROPS1 users on distMembers.REFCMID = users.CMID where users.OBJID=@camid and distName.NAME = @listName; delete distMembers from CMREFORD1 distMembers inner join cmobjnames distName on distName.CMID = distMembers.cmid inner join CMOBJPROPS1 users on distMembers.REFCMID = users.CMID where users.OBJID=@camid and distName.NAME = @listName; SELECT @@ROWCOUNT as "rowCount";
We can now create a framework model to import them into Cognos. First, set up the datasource to the Content Store database.
Then, in framework, run the metadata wizard to import the two SPs.
In both cases, the parameters are the same, so use the following:
Let’s publish it!
Attached in this post is the model.xml, and the two report XMLs.Distro-lists.zip (490 downloads)