- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 06:03 PM
Hi,
I am working on a portal page that will allow our users to do attestations of the Identity Access management access roles. I have a custom table that stores our access roles, this is what we use for our new hires so that we know what company or vendor access to grant them. However, we have to do attestations every 6 months for audit reasons to make sure that the access that was approved is still viable.
I am creating a portal page to help make doing the attestations easier. What I have done so far is create a side bar that shows the different application, the goal is so that the approver will select the application that they want to do the attestation on and which ever one they select, the 2nd widget that displays the table will display a list of the records associated with the selection.
This is an example
I am trying to figure out how to pass the value of the selection from the 1st widget into the 2nd widget but set the filter on the 2nd widget in order to display the corresponding records.
I know that I could use the data table, but I need to give them the ability to approve/rejects all the records or select the ones that they want to select.
Does anyone know how I can go about this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 07:37 PM
I figured it out.
Here is my code;
(function() {
var combinations = {}; // Dictionary to store combinations of field values
var uniqueValues = []; // Array to store unique combinations
// Query the table
var gr = new GlideRecordSecure('u_role_base_access_rbac');
gr.addQuery('u_rbac_system_owner.manager', gs.getUser().getID());
gr.addQuery('u_active', true);
gr.query();
while (gr.next()) {
// Create a composite key for each record based on the two fields
var key = gr.u_rbac_type + '^^' + gr.u_system;
// Store the combination in the dictionary
combinations[key] = {
type: gr.u_rbac_type.toString(),
system: gr.u_system.name.toString()
};
}
// Loop through the combinations dictionary and add each combination to the uniqueValues array
for (var compositeKey in combinations) {
uniqueValues.push(combinations[compositeKey]);
}
var values = uniqueValues; // Return the array of unique values
data.rbac = values;
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 11:07 PM
Hi Dazler,
To pass the value of the selection from the 1st widget into the 2nd widget, you can use the below code in client script widget1 where you need to select the value.
$timeout(function(){
$rootScope.$broadcast('function_name', selectedValue)
},500)
And you can pass these value into widget2 or get these value into any other widget by using below code
$rootScope.$on('function_name_same_as_used_in_widget1',function(event,any_parameter){
//you can fetch the data from widget1
});
Note: Function name which is marked bold as to be same in both the widget.
Please mark helpful if it resolves your query
Best Regards,
Sindhu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 06:36 PM
Hi @SindhuKM
Thank you so much that help, I got that part to work.
I was hoping perhaps you can answer another question. On my first widget, I am pulling data from a table that looks like the below screenshot.
I need these options to display on the side navigation, but I don't want it to display all the records, I want to remove the duplicates and show as a single option. For example, the 2 records in the below screenshot where the system is Zoom I want that to display as one option on the side navigation and then when the user selects it then it will display on the page like this.
I need to base the duplicates off whether these 2 fields (RBAC Type and System) on the table are the same. This is what I have so far
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
var rbacGR = new GlideRecord('u_role_base_access_rbac');
rbacGR.addQuery('u_rbac_system_owner.manager', gs.getUser().getID());
rbacGR.addQuery('u_active', true);
rbacGR.query();
var results = [];
while(rbacGR.next())
{
var rbac = {};
rbac.system = rbacGR.getDisplayValue('u_system.name');
rbac.type = rbacGR.getDisplayValue('u_rbac_type');
results.push(rbac);
}
data.rbac = results.reduce(function(acc,curr,idx){ if(acc.used.indexOf(curr.system) == -1){ acc.used.push(curr.system); acc.rbacs.push(curr) } return acc},{"used":[],"rbacs":[]}).rbacs;
})();
I can only remove duplicate based on 1 field and I need it to be 2. Any idea on how I can adjust my script to account for these 2 fields matching?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 07:37 PM
I figured it out.
Here is my code;
(function() {
var combinations = {}; // Dictionary to store combinations of field values
var uniqueValues = []; // Array to store unique combinations
// Query the table
var gr = new GlideRecordSecure('u_role_base_access_rbac');
gr.addQuery('u_rbac_system_owner.manager', gs.getUser().getID());
gr.addQuery('u_active', true);
gr.query();
while (gr.next()) {
// Create a composite key for each record based on the two fields
var key = gr.u_rbac_type + '^^' + gr.u_system;
// Store the combination in the dictionary
combinations[key] = {
type: gr.u_rbac_type.toString(),
system: gr.u_system.name.toString()
};
}
// Loop through the combinations dictionary and add each combination to the uniqueValues array
for (var compositeKey in combinations) {
uniqueValues.push(combinations[compositeKey]);
}
var values = uniqueValues; // Return the array of unique values
data.rbac = values;
})();