- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2024 08:03 PM
I created a Client Script where it should show a confirmation message first before proceeding with changing the active field from True to False.
I added an alert to check if the script is executing properly because the confirmation message is not appearing.
Every time I change the active field from Tue to False, that alert is appearing but after clicking OK the confirmation message does not pop-up and it wouldn't let me proceed with changing the value on the active field from True to False.
I checked everything, this is the only Client Script under customer_contact table with the type of onCellEdit.
The user that I am impersonating has the proper role.
I checked the pop-up blocker and it is allowed.
I am not sure why the confirmation message is not appearing. Please help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2024 12:24 AM
@tindiz You are doing two mistakes
1) Parameter provided in onCellEdit function are wrong. Remove everything from you script section ang put below code.
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = false;
callback(saveAndClose);
}2) You are using GlideForm API (g_form) which is not supported onCellEdit client script.
Here is your Final code. It will work. Make sure "sn_customerservice_manager" role name is correct.
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = false;
//Type appropriate comment here, and begin script below
if ((newValue == false || newValue == 'false') && g_user.hasRole('sn_customerservice_manager')) {
var confrimation = confirm('Are you sure you want to deactivate this user? This action cannot be undone')
if (confrimation)
saveAndClose = true;
}
callback(saveAndClose);
}
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2024 02:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2024 08:25 PM
@tindiz It seems that the if condition on line number 5 in your script is failing. In all possibility, the following condition may be failing
newValue==='false';
Try to update this to the following and see if it works.
newValue==false;
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2024 08:44 PM
@Sandeep Rajput I changed the script as you suggested and then went to the active field again to change it from true to false and the confirmation message is still not appearing so I can proceed with the action that I would like to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2024 09:34 PM
@tindiz While checking the OOTB onCellEdit client script, I found following method signature.
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
//Type appropriate comment here, and begin script below
callback(saveAndClose);
}
Here
- sysIDs: an array of the sys_ids for all items being edited.
- table: the table of the items being edited.
- oldValues: the old values of the cells being edited.
- newValue: the new value for the cells being edited.
- callback: a callback that continues the execution of any other related cell edit scripts. If true is passed as a parameter, the other scripts are executed or the change is committed if there are no more scripts. If false is passed as a parameter, any further scripts are not executed and the change is not committed.
Since it doesn't specify any fieldName parameter, I am assuming your script is failing because of the same reason.
The if block in your script has a condition
fieldName==='active'
since the method doesn't support fieldName parameter your if condition might be failing due to it.
To confirm this, you can use an
alert(fieldName);
to check if it prints the field name or the table name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2024 11:33 PM - edited 09-28-2024 11:34 PM
@tindiz I have tried the same thing with business rule table giving the access for this table to the desired user. Here is the solution that might be helpful to you.
Juhi Poddar