Name
global.saveFlowDesignerFeatures
Description
Asynchronously save Flow Designer Access Features
Script
var saveFlowDesignerFeatures = Class.create();
saveFlowDesignerFeatures.prototype = Object.extendsObject(AbstractAjaxProcessor, {
saveFeatures: function() {
var glideLists = this.getParameter("sysparm_glideLists");
var featureAccessEnabledChecked = this.getParameter("sysparm_featureAccessEnabled");
try {
var parsedGlideLists = JSON.parse(glideLists);
} catch (e) {
return false;
}
for (var i = 0; i < parsedGlideLists.length; i++){
var gr = new GlideRecord("sys_hub_resource_filter_rule");
var resourceFilterRuleName = this.buildName(parsedGlideLists[i].id);
gr.query("name", resourceFilterRuleName);
if(gr.next()) {
var role = parsedGlideLists[i].innerHTML || "";
gr.setValue("role", role);
gr.update();
}
}
var gr2 = new GlideRecord("sys_hub_resource_filter_rule");
// either make all inactive/active for UI Elements, or else "All UI elements" will override the individual records
if (!featureAccessEnabledChecked) {
gr2.addQuery("resource.name", "All UI Elements");
gr2.query();
while(gr2.next()) {
gr2.setValue("active", true);
gr2.update();
}
} else {
gr2.addQuery("resource.name", "All UI Elements");
gr2.query();
while(gr2.next()) {
gr2.setValue("active", false);
gr2.update();
}
}
return true;
},
buildName: function(name) {
var splitName = name.split('_');
var result = "";
// this removes the "zmyListCollector" and "nonedit" from the beginning and end, respectively
// so we can get the name by itself
splitName.shift();
splitName.pop();
result = splitName.join('_');
return "(Feature Access Page) " + result;
},
type: 'saveFlowDesignerFeatures'
});
Sys ID
36dc22d7735610104f274e3a4cf6a7fe