We use CE primarily for one group of users to see a set of financial and budget reports, which are organized into forlders by report category. Some reports are standard and are run once a night for all users under the Administrator account. Others are user-scheduled and take parameters according to the user's needs. Admin-run reports need to be seen by everyone, but user-scheduled reports should be seen only by that user.
We have customized the code in history.csp and in schedule.csp to implement this requirement - and synchronize the instance counts with the accessible instances.
In history.csp, the WHERE clause on the instance query has been extended as shown below. The
bold line is the search string you would use to find the code insertion point in the file.
Code:
[b]var whereClause = "SI_PARENTID = " + id;[/b]
if ( userName != 'Administrator') // Set a condition for limiting the instances.
{
whereClause += " AND SI_OWNER IN ('Administrator', '" + userName + "')"; // Limit to reports run by user or Administrator.
whereClause += " AND NOT (SI_SCHEDULEINFO.SI_ENDTIME = '4712.12.31' AND"; // Exclude reports scheduled to eternity...
whereClause += " SI_SCHEDULEINFO.SI_SUBMITTER != '" + userName + "')"; // ...by someone else, i.e., Administrator.
}
In available.csp, the code change deals with the instance count displayed for each report, and with the View Last Instance option. (A user can only view the "last" instance if was run by that particular user - or by the Administrator.)
Two custom functions were added at the end of the file:
Code:
function LC_CountHistoryInstances( instanceID)
// This function will count instances not scheduled to eternity by someone else, i.e. Administrator.
{
var qry = "SELECT si_id, SI_SCHEDULEINFO FROM CI_INFOOBJECTS ";
qry += "WHERE SI_PARENTID = '" + instanceID + "' ";
if ( username != 'Administrator' ) { // Limit the instances counted (to match history instances displayed).
qry += "AND SI_OWNER IN ('Administrator', '" + username + "')"; // Limit to reports owned by the user or Administrator.
qry += "AND NOT ( SI_SCHEDULEINFO.SI_ENDTIME = '4712.12.31' AND "; // Exclude instances for "eternity"...
qry += " SI_SCHEDULEINFO.SI_SUBMITTER != '" + username + "' )"; // ... scheduled by someone else.
}
var histInst = iStore.Query(qry);
return histInst.Count;
}
Code:
function lcSecurity( actionItemID, instId, username)
// This function is used to disable View Last Report if the (latest) instance
// is not owned by the logged-on user (unless the user or owner is Administrator).
{
if ( actionItemID == -10008 && instId != -1) // -10008 is View Last Report
try
{
var lastInstOwner = rsLastInst.Item("#" + instId).Properties.Item("SI_OWNER").value;
if ( username != "Administrator" && username != lastInstOwner && lastInstOwner != "Administrator")
return false;
}
catch(e)
{
return true;
}
return true;
}
Calls to the lcSecurity() function were added to code located in the functions WriteActions() and DisplayActionItem. Use the
bold text as a search string to find the 2 locations.
Code:
//[b]if( secinfoObj.CheckAction(actionItem.ID) )[/b] // Replaced with ...
if( secinfoObj.CheckAction(actionItem.ID) && lcSecurity( actionItem.ID, instId, username) ) // User test added.
Calls to the LC_CountHistoryInstances() function were added to code located in the functions DisplayThumbnailItem(), DisplayListItem(), and DisplayActionItem(). Use the
bold text as a search string to find the 3 locations.
Code:
//Response.Write("<div class='list'>" + [b]L_INSTANCES + realObj.Properties.Item("SI_CHILDREN")[/b] + "</div>" + vbCRLF); // Replaced with...
Response.Write("<div class='list'>" + L_INSTANCES + LC_CountHistoryInstances( realObj.Properties.Item("SI_ID")) + "</div>" + vbCRLF); // Show count that History will display.
(The "reports scheduled to eternity" are schedules entered in the CMC, by Administrator, for a very future date. The purpose is to link the object to a File Event, which cannot be done in ePortfolio. As long as the schedule is outstanding, however, reports scheduled in ePortfolio are also dependent on this Event. The date, while arbitrary, was not chosen at random, as Oracle Applications analysts will recognize.)