Define Live Security function

Open the data model you wish to set a Live Security function
https://lh5.googleusercontent.com/2C5BDoV-7uXAghqZzF6CTnBYtY-3fndDl4HVNnj59KoaQYc3AvCOBiILSUmM_5dIR0qC7eUdOHXBGvsFXtxeskh0b1rgpBrP6Bfy8C-sborNfIsmmkrO1bH7KsPi1Vpq1Aoi2xTA81I

Add the function in the SELTRANS section of the dictionary of functions (You have to duplicate it and update it between /* START CONFIG*/ and /* END CONFIG */ see below)

/* START CONFIG */
//version: 2019R2
var securedDims = {};
securedDims["Région"] = getUserAttribute("region");

/* Ajouter ici les autres dimensions sur lequel du live security doit s’appliquer */
/*
securedDims["DIMENSION_NAME_2"] = getUserAttribute("USER_PARAM_2");
*/


/* END CONFIG */

/* MODIFY THE SCRIPT BELOW WITH CAUTION */
var sLogPrefix = "[LIVE_SECURITY] [live-sec-thread-" + Math.floor(Math.random()*16777215).toString(16) + "]"; /* 16777215 is FFFFFF in decimal */

for (var dimId in securedDims)
{
var dim = selection.dm.objName[dimId];
var persoVal = securedDims[dimId];

//Packages.com.digdash.utils.MessageStack.getInstance().addDebug(sLogPrefix + "Applying user filters on: " + dimId + ", persoVal:" + persoVal);
if (dim)
 {
 if (persoVal == null || persoVal.length == 0)
  {
  // user must no see any value
  var persoValuesTab = ["-noval-"];
  var filt = new FilterSelection(dim, -1, -1, [], persoValuesTab);
   selection.setFilter(filt);
  Packages.com.digdash.utils.MessageStack.getInstance().addDebug(sLogPrefix + " Filters (members) on " + dimId + ": [" + persoValuesTab + "]");
  }
 else if (persoVal && persoVal != ".*")
  {
  //user is limited to some value(s)
  var persoValuesTab = persoVal.split("|");
  Packages.com.digdash.utils.MessageStack.getInstance().addDebug(sLogPrefix + " Applying user filters on " + dimId + ": [" + persoValuesTab + "]");

  var exFilter = selection.filterByDimName[dimId];
  if (!exFilter)
   {
   //there is no exisitng filter on that dimension => create a new one
   var filt = new FilterSelection(dim, -1, -1, [], persoValuesTab);
    selection.setFilter(filt);
   Packages.com.digdash.utils.MessageStack.getInstance().addDebug(sLogPrefix + " Resolved filters (members) on " + dimId + ": [" + persoValuesTab + "]");
   }
  else
   {
   //there is already a filter on that dimension => merge (intersect) into a new one
   var filt = new FilterSelection(dim, -1, -1, [], persoValuesTab);
    filt.recalcIds();
    exFilter.recalcIds();
    exFilter = mergeFilters(exFilter, filt);
    origIdsTab = exFilter.origIds;
    selection.setFilter(exFilter);
   Packages.com.digdash.utils.MessageStack.getInstance().addDebug(sLogPrefix + " Resolved filters (origIds) on " + dimId + ": [" + exFilter.origIds + "]");
   }
  }
 else // perso value is .*
 {
  // do nothing, user can see everything
  Packages.com.digdash.utils.MessageStack.getInstance().addDebug(sLogPrefix + " Resolved filters on " + dimId + ": All (.*)");
  }
 }
else
 {
 Packages.com.digdash.utils.MessageStack.getInstance().addError(sLogPrefix + " Dimension " + dimId + "not found");
 }
}

User Attribute

Make sure to add a user parameter (USER_PARAM_1 for example) and fill it for the concerned users (Set .* for other users).
In the following example, admin will be granted to see the DIMENSION_NAME_1 where value A, B or C are present.
https://lh3.googleusercontent.com/pi0GKHieoUS7OOnI0ve5AoidI7shqXqnm4l6mfDTFFZsKvWyOSF6xt_5Pw_X2x9epy5w6AIXF8uhO1l-UdrtB9pPcXCQFT-gQ_a3jGaxbQHdXejAaNEz2YmgkQ1jmmb8OZXAOibXj1g

Live Security to forbid measure display

var show_measure = getUserAttribute('show_measure');
var measureId = 'CA'; // id of the measure to hide

if (show_measure == 'non')
{
var measIndex = selection.indexOfMeasure(measureId);
if (measIndex > 0)
  selection.removeMeasure(measIndex);
}
Tags:
Copyright ©2006-2023 DigDash SAS