ACL condition script examples

Know the phase order

You need to know the order of the phase

This can be done via this query :

select * from scphase

Only show a control when the phase = Concept

Use this script:

if (!g_serviceguid) return false;

var service = JSON.parse(ServiceCatalogInterface.getServiceOverview(g_serviceguid));

return service && service.phase && service.phase.order === 1;

It will check the 'Order' of the phase, for 'Concept' this is always 1. ANy other phase: please check with SMTX to get the Order number.

Only show a control when the phase is minimum X

You need to know the order of the phase

This can be done via this query : select * from ScPhase

When you have the order, use this script, in our example, the order = 5:

//only from phase Final approval CTU

if (!g_serviceguid) return false;

var service = JSON.parse(ServiceCatalogInterface.getServiceOverview(g_serviceguid));

return service && service.phase && service.phase.order >= 5;

Only show when phase is X or Y

// enkel mogelijk in phases concept of Waiting for submission to CTC’ – or -- when the field Open_DOC_Categories_for_Team equals Yes

if (!g_serviceguid) return false;

//check the phase var service = JSON.parse(ServiceCatalogInterface.getServiceOverview(g_serviceguid)); if (service && service.phase && (service.phase.order === 1 || service.phase.order === 17)) return true;

//check the field Open_DOC_Categories_for_Team equals Yes return JSON.parse(ServiceCatalogInterface.getServiceParts(g_serviceguid, ["Open_DOC_Categories_for_Team"])).map(function (part) { return part.value; }).join("") === "Yes";

Exclude Document categories

You can define a number of values of a document part, and deny access to see these documents.

In the example below, we will wotk with the Document part 'DoC_Category'. We want only 'internals' to see them. To define this, we work in the opposite way, we will exclude them for the counterpart, being the 'externals'.

So, the code below excludes the following entries for the users with the role 'External' (as selected Persona).

var documentcategory = JSON.parse(g_data_string).parts.filter(function (p) { return p.internalname === "Doc_Category"; }).map(function (p) { return p.value; }).join("");

if (documentcategory) {

return ["ZA1","ZA2","ZA3","ZB1","ZC2"].indexOf(documentcategory) < 0;

}

return true;

So the Personas that get this ACL, do NOT have access to the values "ZA1","ZA2","ZA3","ZB1","ZC2". This means that they will not see documents that have this category. Please note that you will need hand out access rights for the other personas, see the chapter below.

Include a document category

When you want to give centrain Persona's access to Documents, based on a value in a document part, use this JS condition:

// This ACL gives access to the personas to access these documents

// Please note that we need a second ACL, where this category is excluded for everyone

// we include: ZC1, ZC2,

var documentcategory = JSON.parse(g_data_string).parts.filter(function (p) { return p.internalname === "Doc_Category"; }).map(function (p) { return p.value; }).join("");

if (documentcategory)

{ return ["ZC1","ZC2"].indexOf(documentcategory) >= 0;

}

return false;

Only perform when a template part has a certain value

The example below will be OK when the parth with the internal name 'INTERNAL_NAME' has the value 'CheckValue'.

if (!g_serviceguid) return false;

return JSON.parse(ServiceCatalogInterface.getServiceParts(g_serviceguid, ["INTERNAL_NAME"])).map(function (part) { return part.value; }).join("") === "CheckValue";

Only perform when a template part has a certain value & phase = Concept (1)

// enkel mogelijk in phase concept of when the field Open_DOC_Categories_for_Team equals Yes if (!g_serviceguid) return false;

//check the phase var service = JSON.parse(ServiceCatalogInterface.getServiceOverview(g_serviceguid)); if (service && service.phase && service.phase.order === 1) return true;

//check the field Open_DOC_Categories_for_Team equals Yes return JSON.parse(ServiceCatalogInterface.getServiceParts(g_serviceguid, ["Open_DOC_Categories_for_Team"])).map(function (part) { return part.value; }).join("") === "Yes";

Only perform when a certain template part is different from a value, and the phase equals X

// only active from phase Active (order 3) and // if field Service_Specification is different from Consulting

if (!g_serviceguid) return false; //check the phase var service = JSON.parse(ServiceCatalogInterface.getServiceOverview(g_serviceguid)); if (!(service && service.phase && service.phase.order === 3)) return false;

//check the field Service_Specification if (JSON.parse(ServiceCatalogInterface.getServiceParts(g_serviceguid, ["Service_Specification"])).map(function (part) { return part.value; }).join("") === "Consulting") return false;

return true;

Last updated