Client Script: User Assignment Checker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2024 06:13 AM - edited ‎09-29-2024 06:16 AM
I have a Client Script here where a confirmation message pops-up before proceeding with the user deactivation.
Now, how can I add the following requirement on the script?
If the user being deactivated is the assigned user on the "primary_contact" or "u_authorised_approvers" field on "customer_account" table then an alert message should show up asking to get the assigned user replaced on the mentioned fields first before proceeding with the deactivation.
They cannot proceed with deactivating it unless the user assigned to these fields are replaced.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2024 06:18 AM
I tried to use the below script but it did not work -
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = false;
if ((newValue == false || newValue == 'false') && g_user.hasRole('sn_customerservice_manager')) {
var userID = sysIDs[0]; // Assuming you're deactivating a single user
var userInUse = false;
// Check if user is assigned to "primary_contact" or "u_authorised_approvers"
var gr = new GlideRecord('customer_account');
gr.addQuery('primary_contact', userID);
gr.addOrCondition('u_authorised_approvers', userID);
gr.query();
if (gr.next()) {
userInUse = true;
}
if (userInUse) {
alert('Please replace the assigned user in the primary_contact or u_authorised_approvers fields before deactivation.');
} else {
var confirmation = confirm('Are you sure you want to deactivate this user? This action cannot be undone.');
if (confirmation) saveAndClose = true;
}
}
callback(saveAndClose);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2024 06:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2024 06:59 AM
I even tried to create a Script Include
And called that Script Include in my Client Script but still did not work as expected. Please help.
---
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2024 07:23 AM
Hello @tindiz ,
It is not recommended to use glide record in client script, instead you can use script include called using glide ajax from client script to run server side scripting such as glide record.
Thanks & Regards
Juhi Poddar