Confirmation message is not working/appearing

tindiz
Giga Guru

I created a Client Script where it should show a confirmation message first before proceeding with changing the active field from True to False.

 

tindiz_0-1727578726775.png

 

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.

tindiz_1-1727578886020.png

 

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.

 

 

2 ACCEPTED SOLUTIONS

SANDEEP28
Mega Sage

@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 !!

 

 

 

 

 

 

 

View solution in original post

@SANDEEP28 it works! Thank you so much!!!!!!!!!!!!!!!!!!!

View solution in original post

7 REPLIES 7

Sandeep Rajput
Tera Patron

@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.

 

@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.

tindiz_1-1727581416039.png

tindiz_2-1727581463488.png

 

 

@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.

 

Juhi Poddar
Kilo Patron

@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.

Thank You!
Juhi Poddar